Daily Archives

Articles indexed Tuesday May 11 2010

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

  • How can I strip Python logging calls without commenting them out?

    - by cdleary
    Today I was thinking about a Python project I wrote about a year back where I used logging pretty extensively. I remember having to comment out a lot of logging calls in inner-loop-like scenarios (the 90% code) because of the overhead (hotshot indicated it was one of my biggest bottlenecks). I wonder now if there's some canonical way to programmatically strip out logging calls in Python applications without commenting and uncommenting all the time. I'd think you could use inspection/recompilation or bytecode manipulation to do something like this and target only the code objects that are causing bottlenecks. This way, you could add a manipulator as a post-compilation step and use a centralized configuration file, like so: [Leave ERROR and above] my_module.SomeClass.method_with_lots_of_warn_calls [Leave WARN and above] my_module.SomeOtherClass.method_with_lots_of_info_calls [Leave INFO and above] my_module.SomeWeirdClass.method_with_lots_of_debug_calls Of course, you'd want to use it sparingly and probably with per-function granularity -- only for code objects that have shown logging to be a bottleneck. Anybody know of anything like this? Note: There are a few things that make this more difficult to do in a performant manner because of dynamic typing and late binding. For example, any calls to a method named debug may have to be wrapped with an if not isinstance(log, Logger). In any case, I'm assuming all of the minor details can be overcome, either by a gentleman's agreement or some run-time checking. :-)

    Read the article

  • MySQL GROUP BY and JOIN

    - by christian
    Guys what's wrong with this SQL query: $sql = "SELECT res.Age, res.Gender, answer.*, $get_sum, SUM(CASE WHEN res.Gender='Male' THEN 1 else 0 END) AS males, SUM(CASE WHEN res.Gender='Female' THEN 1 else 0 END) AS females FROM Respondents AS res INNER JOIN Answers as answer ON answer.RespondentID=res.RespondentID INNER JOIN Questions as question ON answer.Answer=question.id WHERE answer.Question='Q1' GROUP BY res.Age ORDER BY res.Age ASC"; the $get_sum is an array of sql statement derived from another table: $sum[]= "SUM(CASE WHEN answer.Answer=".$db->f("id")." THEN 1 else 0 END) AS item".$db->f("id"); $get_sum = implode(', ', $sum); the query above return these values: Age: 20 item1 0 item2 1 item3 1 item4 1 item5 0 item6 0 Subtotal for Age 20 3 Age: 24 item1 2 item2 2 item3 2 item4 2 item5 1 item6 0 Subtotal for Age 24 9 It should return: Subtotal for Age 20 1 Subtotal for Age 24 2 In my sample data there are 3 respondents 2 are 24 yrs of age and the other one is 20 years old.

    Read the article

  • Is it possible to use inheritance in this situation? (Java)

    - by they changed my name
    I have ClassA and ClassB, with ClassA being the superclass. ClassA uses NodeA, ClassB uses NodeB. First problem: method parameters. ClassB needs NodeB types, but I can't cast from the subclass to the superclass. That means I can't set properties which are unique to NodeB's. Second problem: When I need to add nodes toClassB, I have to instantiate a new NodeB. But, I can't do this in the superclass, so I'd have to rewrite the insertion to use NodeB. Is there a way around it or am I gonna have to rewrite the whole thing?

    Read the article

  • How come the [L] flag isn't working in my .htaccess file?

    - by George Edison
    Here are the rules: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ index.php?action=home [L] RewriteRule ^[\w\W]*$ error.php [L] When a page matches the first one, it is supposed to ignore any other further rules. Yet accessing / results in error.php being invoked. Commenting out the second rule works as intended - the page redirects to index.php. What am I doing wrong? Also: is there a better way to write the last line? It's basically a catch-all.

    Read the article

  • What are the features of C#5.0 [closed]

    - by Newbie
    Well I know that there is C#4.0 in dotnet framework 2010. But recently I came across somewhere (possibly in StackOverflow, may be in some answers of Mr. John Skeet) that there is something as C# 5.0(may be in beta). If anyone knows it, could you please highlight about that. Thanks

    Read the article

  • Silverlight TemplateBinding to RotateTransform

    - by Trog Dog
    I am trying to create the simplest Silverlight templated control, and I can't seem to get TemplateBinding to work on the Angle property of a RotateTransform. Here's the ControlTemplate from generic.xaml: <ControlTemplate TargetType="local:CtlKnob"> <Grid x:Name="grid" RenderTransformOrigin="0.5,0.5"> <Grid.RenderTransform> <TransformGroup> <RotateTransform Angle="{TemplateBinding Angle}"/> <!-- This does not work --> <!-- <RotateTransform Angle="70"/> --> <!-- This works --> </TransformGroup> </Grid.RenderTransform> <Ellipse Stroke="#FFB70404" StrokeThickness="19"/> <Ellipse Stroke="White" StrokeThickness="2" Height="16" VerticalAlignment="Top" HorizontalAlignment="Center" Width="16" Margin="0,2,0,0"/> </Grid> </ControlTemplate> Here's the C#: using System.Windows; using System.Windows.Controls; namespace CtlKnob { public class CtlKnob : Control { public CtlKnob() { this.DefaultStyleKey = typeof(CtlKnob); } public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(CtlKnob), null); public double Angle { get { return (double)GetValue(AngleProperty); } set { SetValue(AngleProperty,value); } } } }

    Read the article

  • Ubuntu Wired network(ethernet does not work)

    - by badnaam
    It was working just fine, until the other day I yanked it out. The wireless works just fine on the same router. If I login to a windows 7 instance on this dual boot laptop then the ehternet works just fine. So it's not a hardware, cable or router issue. The card even gets an ip, but I can't connect to the internet. Here are the details from route, iptables, ifconfig, ping etc. Any ideas? I have been struggling with this for day, none seems to have an answer. http://pastie.org/954816

    Read the article

  • Having a little trouble with this Java code. Beginner probably mixing some things with C#.

    - by Sergio Tapia
    package practico1; /** * Programador: Sergio Tapia Gutierrez * Fecha: Lunes 10, Mayo - 2010 * Practico: 1 */ public class Main { public static void main(String[] args) { System.out.println("Esta es una pequena aplicacion para mostrar los"); System.out.println("distintos tipos de datos que existen en Java 6."); //boolean, char, byte, short, int, long, float, double, String ejemplosBoolean(); } public void ejemplosBoolean(){ } } So, I'm just testing some things out, but I'm getting an error claiming that I'm trying to run ejemplosBoolean() in a static context when it isn't a static method. My question is, in Java do methods have to have static in order to use them even if they are in the same class?

    Read the article

  • Custom UIView built with Interface Builder accessible/positionable via Interface Builder

    - by Nader
    This shouldn't be this confusing. I have a custom UIView with a bunch on controls on it. UILabels, buttons, etc. I've created this Nib using Interface Builder. I want to be able to position this custom uiview on another UIView using the interface builder. How do I link my UIView custom class, to the nib? initWithCoder gets called, but I want this class to get loaded from the nib. Thanks

    Read the article

  • Perl daemon script for message queue hanging for 20 seconds after each process. Why?

    - by Mike Diena
    I have daemon script written in Perl that checks a database tables for rows, pulls them in one by one, sends the contents via HTTP post to another service, then logs the result and repeats (only a single child). When there are rows present, the first one is posted and logged immediately, but every subsequent one is delayed for around 20 seconds. There are no sleep()'s running, and I can't find any other obvious delays. Any ideas?

    Read the article

  • Rich-Text Editing of Word Documents on the Web via ASP.NET

    - by Caveatrob
    My users upload Word 2007 documents to our site and I'd like to load them into a rich edit control of some kind so the users can make modifications/ comment, etc. What mechanisms are available to: load the Word document via ASP.NET, and parse/format/display the document in a rich editing control? Also, what kinds of rich editing controls are best to use in this circumstance?

    Read the article

  • T-SQL Tuesday #006: LOB, row-overflow and locking behavior

    - by Michael Zilberstein
    This post is my contribution to T-SQL Tuesday #006 , hosted this time by Michael Coles . Actually this post was born last Thursday when I attended Kalen Delaney's "Deep dive into SQL Server Internals" seminar in Tel-Aviv. I asked question, Kalen didn't have answer at hand, so during a break I created demo in order to check certain behavior. Demo goes later in this post but first small teaser. I have MyTable table with 10 rows. I take 2 rows that reside on different pages. In first session...(read more)

    Read the article

  • Loading attribute in XPATH, problem

    - by Nguyen Quoc Hung
    I've got a question about loading attribute in XPATH. I write short XML code to test: <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="testDate.xsl"?> <element attribute="1/1/2100"> Hung </element> My XSL code: <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!--Handle the document: set up HTML page--> <xsl:template match="/"> <html> <head> </head> <body> This is a test <xsl:value-of select="element@attribute"/> </body> </html> </xsl:template> </xsl:stylesheet> Why it produces an error when loading the stylesheet? Would you please help me explain this? Thank you

    Read the article

  • How do I DYNAMICALLY cast in C# and return for a property

    - by ken-forslund
    I've already read threads on the topic, but can't find a solution that fits. I'm working on a drop-down list that takes an enum and uses that to populate itself. i found a VB.NET one. During the porting process, I discovered that it uses DirectCast() to set the type as it returns the SelectedValue. See the original VB here: http://jeffhandley.com/archive/2008/01/27/enum-list-dropdown-control.aspx the gist is, the control has Type _enumType; //gets set when the datasource is set and is the type of the specific enum The SelectedValue property kind of looks like (remember, it doesn't work): public Enum SelectedValue //Shadows Property { get { // Get the value from the request to allow for disabled viewstate string RequestValue = this.Page.Request.Params[this.UniqueID]; return Enum.Parse(_enumType, RequestValue, true) as _enumType; } set { base.SelectedValue = value.ToString(); } } Now this touches on a core point that I think was missed in the other discussions. In darn near every example, folks argued that DirectCast wasn't needed, because in every example, they statically defined the type. That's not the case here. As the programmer of the control, I don't know the type. Therefore, I can't cast it. Additionally, the following examples of lines won't compile because c# casting doesn't accept a variable. Whereas VB's CType and DirectCast can accept Type T as a function parameter: return Enum.Parse(_enumType, RequestValue, true); or return Enum.Parse(_enumType, RequestValue, true) as _enumType; or return (_enumType)Enum.Parse(_enumType, RequestValue, true) ; or return Convert.ChangeType(Enum.Parse(_enumType, RequestValue, true), _enumType); or return CastTo<_enumType>(Enum.Parse(_enumType, RequestValue, true)); So, any ideas on a solution? What's the .NET 3.5 best way to resolve this?

    Read the article

  • problem using the xsl method for-each

    - by joe
    Using XSL I am trying to turn this XML: <book><title>This is a <b>great</b> book</title></book> into this XML: <book>This is a <bold>great</bold> book</book> using this xsl: <xsl:for-each select="book/title/*"> <xsl:choose> <xsl:when test="name() = 'b'"> <bold> <xsl:value-of select="text()"/> </bold> </xsl:when> <xsl:otherwise> <xsl:value-of select="text()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> but my output is looking like this: <book><bold>great</bold></bold> Can anyone explain why the root text of <title> is getting lost? I believe my for-each select statement may need to be modified but I can't figure out what is should be. Keep in mind that I cannot use an <xsl:template match> because of the complexity of my style sheet. Thanks!

    Read the article

  • xslt test if a variable value is contained in a node set

    - by Aamir
    I have the following two files: <?xml version="1.0" encoding="utf-8" ?> <!-- D E F A U L T H O S P I T A L P O L I C Y --> <xas DefaultPolicy="open" DefaultSubjectsFile="subjects.xss"> <rule id="R1" access="deny" object="record" subject="roles/*[name()!='Staff']"/> <rule id="R2" access="deny" object="diagnosis" subject="roles//Nurse"/> <rule id="R3" access="grant" object="record[@id=$user]" subject="roles/member[@id=$user]"/> </xas> and the other xml file called subjects.xss is: <?xml version="1.0" encoding="utf-8" ?> <subjects> <users> <member id="dupont" password="4A-4E-E9-17-5D-CE-2C-DD-43-43-1D-F1-3F-5D-94-71"> <name>Pierre Dupont</name> </member> <member id="durand" password="3A-B6-1B-E8-C0-1F-CD-34-DF-C4-5E-BA-02-3C-04-61"> <name>Jacqueline Durand</name> </member> </users> <roles> <Staff> <Doctor> <member idref="dupont"/> </Doctor> <Nurse> <member idref="durand"/> </Nurse> </Staff> </roles> </subjects> I am writing an xsl sheet which will read the subject value for each rule in policy.xas and if the currently logged in user (accessible as variable "user" in the stylesheet) is contained in that subject value (say roles//Nurse), then do something. I am not being able to test whether the currently logged in user ($user which is equal to say "durand") is contained in roles//Nurse in the subjects file (which is a different xml file). Hope that clarifies my question. Any ideas? Thanks in advance.

    Read the article

  • Trigger jQuery Qtip on FullCalendar dayClick

    - by Tim
    Hello, I have a jquery fullcalendar. I would like to trigger jquery qtip when I click on a day to bring up a list of options. This question is similar to this question already posted, however different enough to warrant a new question. There is an event callback for this but I am unsure how to integrate this with jQuery Qtip All help is appreciated. Thanks, Tim

    Read the article

  • Xpath query to select node when attribute does not exist? [closed]

    - by Antoine
    I want to select nodes for which a specific attribute does not exist. I've tried the Not() function, but it doesn't work. Is there a way for this? Example: The following Xpath query: group/msg[not(@owner)] Should retrieve the first node but not the 2nd one. However, both SketchPath (tool to test Xpath queries) and my C# code consider that the 2 nodes are ok. <group> <msg id="EVENTDATA_CCFLOADED_XMLCONTEXT" numericId="14026" translate="False" topicId="302" status="translated" > <text>Context</text> <comment></comment> </msg> <msg id="EVENTDATA_CCFLOADED_XMLCONTEXT_HELP" numericId="14027" translate="False" topicId="302" status="translated" owner="EVENTDATA_CCFLOADED_XMLCONTEXT" > <text>Provides the new data displayed in the Object.</text> <comment></comment> </msg> </group> In fact the Not() function works correctly, it's just that I had other conditions and parentheses weren't set correctly. errare humanum est.

    Read the article

  • Filtering most out of XML with XSL?

    - by Gnudiff
    I need to transform a lot of XML files (Fedora export) into a different kind of XML. Trying to do it with XSL stylesheets and checking with the msxsl transformer. Supposedly I have xml file like this (assuming there are actually other nodes inside AAA, OBJ, amd all other nodes), Source.XML: <DOC> <AAA> <STUFF>example</STUFF> <OBJ> <OBJVERS id="A1" CREATED="2008-02-18T13:28:08.245Z"/> <OBJVERS id="A2" CREATED="2008-02-19T10:42:41.965Z"/> <OBJVERS id="A13" CREATED="2009-03-16T12:43:11.703Z"/> </OBJ> </AAA> <FFF/> <GGG/> <DDD> <FILE /> </DDD> </DOC> Which I need to look something like this (Target.XML): <MYOBJ> <ELEM>contents of OBJVERS with the biggest id OR creation date (whichever is easier to do) go here</ELEM> <IMAGE> contents of <FILE> node go here</IMAGE> </MYOBJ> The main problem that I have is that since I am new to XSL (and for this particular task do not have enough time to learn it properly) is that I can't understand how to tell XSL processor not to process anything else, I keep getting output from , for example. Update: basically, I solved this problem meanwhile. I will post my own answer and close the question. Update2: OK, Andrew's answer works, too, so I am just accepting it. :)

    Read the article

  • Upgrading dojo in Spring-js from 1.3 to 1.4

    - by peirix
    We have a project where we're using Spring-js. With it comes Spring-dojo and the full dojo package. But in the current version of Spring-js (2.0.9), it's using dojo 1.3. Is there a way to upgrade manually to dojo 1.4? Or even a new Spring-js.jar-file that can be donwloaded that uses dojo 1.4?

    Read the article

  • Large file download for a Rails project

    - by Horace Ho
    One client project will be online two months later. One of the requirements changed is to support large files (10 to 15MB per RAW camera file, expected 1000 to 5000 files download per day) download worldwide for their customers. The process will be: there is upload screen via paperclip to the rails local public folder a hourly task to upload to web storage (S3?) update the download url from paperclip url to the web url Questions: is there a gem/plug-in for this purpose? if no, any gem/plug-in for S3 to recommend? Questions about the storage provider: is S3 recommended? or other service to recommend? The baseline is: the client's web server does not and will not have the bandwidth to handle the downloads. Thanks

    Read the article

  • Many-To-Many Query with Linq-To-NHibernate

    - by rjygraham
    Ok guys (and gals), this one has been driving me nuts all night and I'm turning to your collective wisdom for help. I'm using Fluent Nhibernate and Linq-To-NHibernate as my data access story and I have the following simplified DB structure: CREATE TABLE [dbo].[Classes]( [Id] [bigint] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](100) NOT NULL, [StartDate] [datetime2](7) NOT NULL, [EndDate] [datetime2](7) NOT NULL, CONSTRAINT [PK_Classes] PRIMARY KEY CLUSTERED ( [Id] ASC ) CREATE TABLE [dbo].[Sections]( [Id] [bigint] IDENTITY(1,1) NOT NULL, [ClassId] [bigint] NOT NULL, [InternalCode] [varchar](10) NOT NULL, CONSTRAINT [PK_Sections] PRIMARY KEY CLUSTERED ( [Id] ASC ) CREATE TABLE [dbo].[SectionStudents]( [SectionId] [bigint] NOT NULL, [UserId] [uniqueidentifier] NOT NULL, CONSTRAINT [PK_SectionStudents] PRIMARY KEY CLUSTERED ( [SectionId] ASC, [UserId] ASC ) CREATE TABLE [dbo].[aspnet_Users]( [ApplicationId] [uniqueidentifier] NOT NULL, [UserId] [uniqueidentifier] NOT NULL, [UserName] [nvarchar](256) NOT NULL, [LoweredUserName] [nvarchar](256) NOT NULL, [MobileAlias] [nvarchar](16) NULL, [IsAnonymous] [bit] NOT NULL, [LastActivityDate] [datetime] NOT NULL, PRIMARY KEY NONCLUSTERED ( [UserId] ASC ) I omitted the foreign keys for brevity, but essentially this boils down to: A Class can have many Sections. A Section can belong to only 1 Class but can have many Students. A Student (aspnet_Users) can belong to many Sections. I've setup the corresponding Model classes and Fluent NHibernate Mapping classes, all that is working fine. Here's where I'm getting stuck. I need to write a query which will return the sections a student is enrolled in based on the student's UserId and the dates of the class. Here's what I've tried so far: 1. var sections = (from s in this.Session.Linq<Sections>() where s.Class.StartDate <= DateTime.UtcNow && s.Class.EndDate > DateTime.UtcNow && s.Students.First(f => f.UserId == userId) != null select s); 2. var sections = (from s in this.Session.Linq<Sections>() where s.Class.StartDate <= DateTime.UtcNow && s.Class.EndDate > DateTime.UtcNow && s.Students.Where(w => w.UserId == userId).FirstOrDefault().Id == userId select s); Obviously, 2 above will fail miserably if there are no students matching userId for classes the current date between it's start and end dates...but I just wanted to try. The filters for the Class StartDate and EndDate work fine, but the many-to-many relation with Students is proving to be difficult. Everytime I try running the query I get an ArgumentNullException with the message: Value cannot be null. Parameter name: session I've considered going down the path of making the SectionStudents relation a Model class with a reference to Section and a reference to Student instead of a many-to-many. I'd like to avoid that if I can, and I'm not even sure it would work that way. Thanks in advance to anyone who can help. Ryan

    Read the article

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