Monday, February 21, 2011

What should a front end developer expect from a copywriter?

I'm working on a site and the client has hired a copy writer to supply the text... which has been an absolute nightmare. I'm wondering, what is an acceptable level of service one could expect from a copy writer who has been asked to write copy specifically for the web.

Is it unreasonable to expect them to have some basic markup skills, such as being able to encode html entities, create paragraphs and links and so on?

Does anyone here have any sort of checklist they use when saying what they will and will not accept as copy for a website?

From stackoverflow
  • No ... I would expect nothing more than a Word document. If you get more than that, you are lucky.

  • I wouldn't expect them to know markup. Their job is to write, not to write HTML - that's your job ;) I interact with about 5 authors regularly, and I only ever see a .doc file, which I convert to HTML, and then hand-clean to perfection before translating it into Markdown syntax...it's a labor of love.

  • No, I would not expect a copywriter to supply ready-made html that you can just pick up and drop in (as others have pointed out, that's your role as the web developer).

    However, I would hope that the copywriter was "web aware":

    • That they were writing the text with a copy of the site design in front of them, knowing where the particular piece of text was going to sit - so they don't deliver a 70 or 80 words for a box that can really only hold 50.

    • That they are writing with SEO in mind (anyone who claims to be a web copywriter should) - that they understand things like keyword density etc.

    • They should be able to clearing indicate what should be "marked up" with the copy - hyperlinks, bold, italics etc.

    • I prefer to receive my copy as plain-text rather than any rich-text (word documents etc.) Although you can't expect markup, getting a .txt file is almost as good for being able to copy & paste it into html. It stops things like word-style quotes from being included in the html and makes working cross-platform a lot easier.

    Martin : Problem is, the OP said his client hired the copywriter. If you were hiring a copy writer, then yes, expect all this. If someone else is, don't expect anything.
    gargantaun : I was asking for future reference, and my contract with clients can stipulate how I accept assets, so in future I'll work these point into it.

QuickTime - AVID, ITU-R 601 (16-235) option

Hi! Excuse for my English

I need to import the .mov file using the AVID codec. In AVID Composer program in import settings it is possible to customise Colour Levels by installation of options RGB (0-255) or 601 (16-235).

How it is possible to set in a code this option (601)?

I tried to set her when setting session:

    long lwidth;
    CHECK_FAILED( m_pMt->get_Pixels(&lwidth) );
    SInt32 width = lwidth;
    number = CFNumberCreate( NULL, kCFNumberSInt32Type, &width );
    CFDictionaryAddValue( pixelBufferAttributes, kCVPixelBufferWidthKey, number );
    CFRelease( number );

    long lheight;
    CHECK_FAILED( m_pMt->get_Lines(&lheight) );
    SInt32 height = lheight;
    number = CFNumberCreate( NULL, kCFNumberSInt32Type, &height );
    CFDictionaryAddValue( pixelBufferAttributes, kCVPixelBufferHeightKey, number );
    CFRelease( number );

    double gamma = 2.199997;
    // Always seems to equal 2.5 for RGB colorspaces and 2.199997 for YUV
    number = CFNumberCreate( NULL, kCFNumberDoubleType, &gamma );
    CFDictionaryAddValue( pixelBufferAttributes, kCVImageBufferGammaLevelKey, number );
    CFRelease( number );

    CFDictionaryAddValue(pixelBufferAttributes, kCVImageBufferYCbCrMatrixKey, kCVImageBufferYCbCrMatrix_ITU_R_601_4);

    CHECK_OSSTATUS( ICMDecompressionSessionCreate(NULL, imageDesc, NULL, pixelBufferAttributes, &trackingCallbackRecord, &m_decompressionSession) );

But it not worked.

From stackoverflow
  • Sorry to be the one to tell you, but I am afraid there is no way to configure these settings programmatically ( at least I found no way to do it ) as they are AVID codec specific.

    You might be able to invoke the same import settings dialog used by AVID Media Composer, though, using the

    MovieImportDoUserDialog()
    

    API function.

    Edit:

    This might be too obvious, but have you tried to simply request YUV data from the decompression session by setting the pixel format type key in your source frame description dictionary to a YUV pixel format?

    You can do this by adding the following block to your code:

    // request YUV 8 Bit 4:2:2 output from the decompression session
    SInt32 pixel_format = k2vuyPixelFormat; // this should be '601 (16-235)' by definition
    number = CFNumberCreate( NULL, kCFNumberSInt32Type, & pixel_format );
    CFDictionaryAddValue( pixelBufferAttributes, kCVPixelBufferPixelFormatTypeKey, number );
    CFRelease( number );
    
    Vitaliy : could you explain how it do?

How can I get the element the caret is in with Javascript, when using contentEditable?

Hi,

Let's say I have some HTML code like this:

<body contentEditable="true">
   <h1>Some heading text here</h1>
   <p>Some text here</p>
</body>

Now the caret (the blinking cursor) is blinking inside the H1 element, let's say in the word "heading". How can I get the name of the element the caret is in with JavaScript? Here I would like to get "h1".

This needs to work only in WebKit (it's embeded in an application). It should preferably also work for selections.

If this is truly trivial, I apologize. My knowledge of JavaScript (and DOM) is sorely lacking.

From stackoverflow
  • Firstly, think about why you're doing this. If you're trying to stop users from editing certain elements, just set contenteditable to false on those elements.

    However, it is possible to do what you ask. The code below works in Safari 4 and will return the node the selection is anchored in (i.e. where the user started to select, selecting "backwards" will return the end instead of the start) – if you want the element type as a string, just get the nodeName property of the returned node. This works for zero-length selections as well (i.e. just a caret position).

    function getSelectionStart(){
        var node = document.getSelection().anchorNode;
        var startNode = (node.nodeName == "#text" ? node.parentNode : node);
        return startNode;
    }
    
    Lucas : I'm not trying to block the user in any way, I really just need the name of the node so I can update a part of the UI. Thank you for providing the answer, this works great.

How Do I Copy a table from one Access DB to another Access DB

I am trying to automate a process to create a secondary database from a primary. Both DB's (MS Access) contain one table; the table in the secondary DB is a subset of the table in the primary.

Is there a simple way to copy a recordset frone one DB to another? I am using VBScript and ADO.

Thanks!

From stackoverflow
  • You can run Insert queries referencing external Access database files files (MDB, ACCDB, etc). For example:

    strSQL = "INSERT INTO ServiceRecordInvoices " & _
        "( sriID, sriServiceRecordID, sriInvoiceDate, sriInvoiceNumber, " & _
                                    "sriDescription, sriInvoiceAmount ) " & _
        " IN '" & strDatabasePathandNameTo & "' " & _
        "SELECT srpID, srpServiceRecordID, srpInvoiceDate, srpInvoiceNumber, " & _
                                    "srpParts, srpPartsAmount " & _
        "FROM ServiceRecordParts IN '" & strDatabasePathandNameFrom & "';"
    

    Note the two string variables strDatabasePathandNameTo and strDatabasePathandNameFrom. The above dynamic SQL code will work fine in either DAO or ADO.

    If the two tables are identical then you could use the following (untested):

    strSQL = "INSERT INTO ServiceRecordInvoices.* " & _
        " IN '" & strDatabasePathandNameTo & "' " & _
        "SELECT * " & _
        "FROM ServiceRecordParts IN '" & strDatabasePathandNameFrom & "';"
    
  • Try the CopyObject method:

    DoCmd.CopyObject "DestinationDatabaseName", "NewName", acTable, "SourceTable"
    

How to get instances in all private fields of an object?

I would like to use reflection to investigate the private fields of an object as well as get the values in those fields but I am having difficult finding the syntax for it.

For example, an object has 6 private fields, my assumption is that I could fetch their FieldInfo with something like

myObject.GetType().GetFields(BindingFlags.NonPublic)

but no dice - the call returns an array of 0.

Whats the correct syntax to access fields?

From stackoverflow
  • BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static
    
    George Mauer : Ahh, its the Instance that I was missing
    leppie : Just added the static bit in case you needed that too :)
  • You should also add BindingFlags.Instance

    myObject.GetType().GetFields(BindingFlags.NonPublic|BindingFlags.Instance)
    
  • You've overridden the default flags, so you need to add Instance back in...

    myObject.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
    
    Meta-Knight : +1 for the explanation..
  • Since you want to retrieve both fields and values:

    from field in myObject.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
    select new
    {
        Field = field,
        Value = field.GetValue(myObject)
    };
    

Matching form entries with javascript?

Hello,

I have a form with markup like this....

Which voucher did you cut out

<div class="answer item1">
  <input type="checkbox" name="downloaded_vouchers[answer1]" id="answer1" value="1"/>
   <label for="answer1">Answer 1</label>
</div>
<div class="answer item1">
   <input type="checkbox" name="downloaded_vouchers[answer1]" id="answer1" value="1"/>
   <label for="answer1">Answer 1</label>
</div>

Which voucher did you use

 <div class="answer item1">
  <input type="checkbox" name="used_vouchers[answer1]" id="usedanswer1" value="1"/>
   <label for="answer1">Answer 1</label>
</div>
<div class="answer item1">
   <input type="checkbox" name="used_vouchers[answer1]" id="usedanswer1" value="1"/>
   <label for="answer1">Answer 1</label>
</div>

I need to be able to somehow, on submition of the form check that the voucher cut matches the one that was used, there is some validation server side but I need to do some client side as well and have no idea where to start, I need to use straight javascript no jquery or similar, can anyone help?

From stackoverflow
  • something like this....

       <script type="text/javascript">
        function validate( )
        {
            // use document.getElementById to get the form item
            var item = document.getElementById("yourElement");
            if ( somecondition == true )
            {
                alert("good to go");
                // allow the form to post
                return true;
            }
            else
            {
                alert("I don't think so");
                // return false so the form will not post
                return false;
            }
        }
        </script>
    
        <form onsubmit="Validate();" >
        </form>
    

    returning true from the onsubmit method will send the form through, returning false will not

Asp.net MVC - Returning to "host" controller when using partial views

I have a controller called Parameters which allows some parameters common to my object model to be edited/viewed. Creating/viewing is performed using a couple of partial views - ShowParameters.ascx and CreateParameters.ascx.

I have a number of other controllers that all use ShowParameters.ascx to show their related Parameters. That works fine.

However, I have a problem with my CreateParameters.ascx partial view. It calls an action named CreateParameter in my Parameters controller to create the parameter. My problem is, I would like it to return to the previous controller and show the Index view for that controller, so that the user can see that the parameter has been created.

How can my Parameters controller determine which controller it should return to?

Thanks,

Tubby

From stackoverflow
  • You could pass an additional returnUrl parameter to your CreateParameter action so that it will redirect to this given url. And in your CreateParameters.ascx partial view you could pass the current controller name and action when you construct the link.

    Another option would be to always redirect to the Request.UrlReferrer inside your CreateParameter action.

.NET app taking long time to show pages

I have a .NET web app that is taking a long time to load each page. I think there is network activity that is going on or calls to other sites. How can I track what network / internet activity is going on when the page is loading? Is there some utility that would allow me to trace activity?

From stackoverflow
  • You should try Fiddler2. It is a local proxy that tracks all the http activity in and out of your box. If you need to check other protocols, you should look into Wireshark. Wireshark allows you to analyze all traffic in and out of your box.

  • I had a problem along those lines a few years ago. I installed WinPcap on the server and had it log all of the network activity. Turns out an errant 3rd party control was sending ~1MB of garbage data back to the server every time a client callback of any sort occurred. I removed it and the page load/callback performance shot up about 500%.

JAVA 6 ServiceLoader

I recently posted a question regarding a way to define the implementation of an abstract service on the client side.

dfa mentioned java.util.ServiceLoader as a solution for my problem.

I ended up going in a similar way, though not using ServiceLoader directly, mainly because i was using JDK 5. But another SOer jut went into panic when dfa mentioned ServiceLoader.

I am wondering what are the main problems with the ServiceLoader implementation. Though limited it seems a good way to solve this issue without going full out on some third party library like Guice

From stackoverflow
  • ServiceLoader is less general than a full dependency injection framework like Spring or Guice. It is designed to lazily load services, that can be deployed at run-time. Therefore ServiceLoader is especially useful for plugins.

    For a complete answer you must ask to Tom Hawtin Tackline.

    Nuno Furtado : My feelings exactly, this is the reason i posted this question. To understand, if any, the reasons behind the dislike of this feature

How to add combo box in WMD

How to add combo box in WMD(Markdown)

From stackoverflow
  • Markdown doesn't have any special syntax for making a dropdown like it does lists. Instead, you would need to insert actual HTML directly into your Markdown code. That may or may not work, depending on what html tags (if any) are allowed during entry.

Is it possible to have yui editor change paragraph style without selecting text?

Is it possible to change the behavior of the yui text editor so that when you make markup changes (via the toolbar bar buttons), for example changing from a paragraph to say a heading or to a list, and you dont have any text selected it assumes you mean the current block that the cursor is in

So to change a paragraph to a heading rather than selecting the whole line you just place the cursor somewhere in the paragraph and select heading from the styles drop down.

From stackoverflow

Is there a way to create an uncompressed zip from PHP?

Is there a way to create an uncompressed ZIP (level 0) from PHP? I can't find any info in the php documentation.

From stackoverflow
  • You can use exec() to run any command on the server, in which case it will depend on the environment (Linux, windows, etc.)

  • If the zip tool is installed on your server, you can always use the shell_exec() function to execute an external command. That way you can most likely create an uncompressed zip file.

  • According to php.net’s bugtracker (and bug #41243) this functionality is not available in the built-in zip utilities. For now you have to shell out.

  • Thank you, guys!

    I found a solution using pear's late Archive_Zip library. There's a bug in it causing corrupted files when using no_compression parameter. The solution found at http://pear.php.net/bugs/bug.php?id=7871 solved that problem!

Why does my regular expression select everything?

Hey guys, I'm trying to select a specific string out of a text, but I'm not a master of regular expressions. I tried one way, and it starts from the string I want but it matches everything after what I want too.

My regex:

\nSCR((?s).*)(GI|SI)(.*?)\n

Text I'm matching on.

Hierbij een test

SCR
S09
/vince@test.be
05FEB
GI BRGDS OPS

middle text string (may not selected)

SCR
S09
05FEB
LHR
NPVT700 PVT701 30MAR30MAR 1000000 005CRJ FAB1900 07301NCE DD
/ RE.GBFLY/
GI BRGDS

The middle string is selected, it only needs the SCR until the GI line.

From stackoverflow
  • To match from a line starting with SCR to a line starting with GI or SI (inclusive), you would use the following regular expression:

    (?m:^SCR\n(?:^(?!GI|SI).*\n)*(?:GI|SI).*)
    

    This will:

    • Find the start of a line.
    • Match SCR and a new line.
    • Match all lines not starting with GI or SI.
    • Match the last line, requiring there to be GI or SI (this prevents it from matching to the end of the string if there is no GI or SI.
    Blixt : I just changed my regex a bit, inspired by Gumbo. His regular expression took into account the fact that if a group doesn't have a `GI` or `SI` line, the regular expression shouldn't match. Now my regex and his second regex are pretty similar, except that mine uses the start of line anchor `^` instead of matching a new line.
  • Use the non-greedy quantifier also on the first quantifier:

    \nSCR((?s).*?)(GI|SI)(.*?)\n
    

    Or you could use a negative look-ahead assertion (?!expr) to capture just those lines that do not start with either GI or SI:

    \nSCR((?:\n(?!GI|SI).*)*)\n(?:GI|SI).*\n
    

Detecting for Pessimistic lock in VB6

I have a database system developed in VB6, and we have a scenario where more than one user may register at the same time triggering an insert in the database. I have used normal sqlconnection and recordset to make the insert and i initialize it with a pessimistic lock. Now how can i check in my application before inserting a record, if the table has been locked or not, thus if the table being inserted to has been locked currently i can alert the user that the table is in use or i can store his data temporarily and insert it once the lock is released. The underlying database is Access and the application is across multiple systems with database on a server.

From stackoverflow
  • You might want to read through Locking Shared Data by Using Recordset Objects in VBA. Most of it applies to VB6 as well as VBA.

    It isn't really "normal" to lock a whole table, and you can't even do it via ADO and the Jet OLE DB Provider. Your question doesn't provide enough information to suggest any specific course of action.

    You don't "check before inserting" either. Applications should be designed to stumble over locks relatively rarely. When they do, you deal with this as an exception. This is reflected in both the DAO and ADO APIs.

How do I best organize a Visual Studio 2008 + Qt Codebase?

I have a legacy MFC app I am building in VS2008 with both x86 and x64 builds. I'm trying to add Qt support to it so I can innovate more quickly in the UI.

It appears Qt has a large number of compile options that I may want to tweak specifically for my app (not source code changes...I want to be LGPL and generate the normal QtCore4.dll, etc.)

I first considered installing Qt SDK separately and adding the global pointers to the includes and libs. However, the fact that I want to tailor the compile option to my product (and do both x86 and x64) meant perhaps I should build Qt SDK into my master app solution (a set of projects in my master solution). However, that has just been a huge mess because Qt dynamically generates .cpp files and compiles them and they don't honor the projects settings (so includes go missing, etc.)

What's the best way to do this? I can't do x86 and x64 with one Qt SDK install because all the libs will get built either one way or the other, not both. Do I need to side-by-side Qt SDKs or am I on the right track trying to build it into my app's source base?

MikeG

From stackoverflow
  • If you're going to be using Qt with your application, I'd strongly recommend changing your build system to use CMake.

    It makes it much simpler to support out of source builds for Qt, and have multiple build settings for 32/64bit, platform independence, and (potentially most importantly) very easy migration to new (or multiple) Visual Studio versions.

    When I started with Qt, I was miserable until I started using this - mostly because the auto generated files were completely causing me grief in source control. Being able to build out of your source tree is very, very compelling, and CMake makes that easy.

Zend_Loader_Autoload setup

I'm running Zend on a XP machine, and i had my neat layout working etc when i changed something (i'm still experimenting to find out what broke it) but for the moment, this is my debug issue atm

Debug Warning: /BHAA_ZEND/library/Zend/Loader.php line 165 - fopen(./views\helpers/Doctype.php): failed to open stream: No such file or directory
Debug Warning: /BHAA_ZEND/library/Zend/Loader.php line 165 - fopen(./views\helpers/HeadMeta.php): failed to open stream: No such file or directory

Lots of Debug warnings from Zend_Loader_Autoload suggest that the autoloader needs to be set up perfectly, but doesn't suggest any examples. I'm 100% sure that i'm using PATH_SEPERATOR in all my config and ini files. My index.php look like this

<?php
define('BASE_PATH', realpath(dirname(__FILE__) . '/../'));

// Define path to application directory
define('APPLICATION_PATH', BASE_PATH . '/application');

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Include path
set_include_path(
    BASE_PATH . '/library'
    . PATH_SEPARATOR . get_include_path()
);

require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();

/** Zend_Application */
require_once 'Zend/Application.php';  

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini'
);

$application->bootstrap();
$application->run();
?>

Should i move the AutoLoader to the Bootstrap.php file?

From stackoverflow
  • What did you change? Did you upgrade the Zend Framework Library? Did you change your server environment?

    Why do you include further files if you want to use autoloader?

    jason : And... perfect example of what comments are good for.

Difference between <xs> and <xsd> tags in XML schema file?

What is the difference between the <xs> and <xsd> tags in XML schema files?

From stackoverflow
  • from w3.org

    The XML representation of schema components uses a vocabulary identified by the namespace name http://www.w3.org/2001/XMLSchema. For brevity, the text and examples in this specification use the prefix xs: to stand for this namespace; in practice, any prefix can be used.

    in the end xs or xsd are only prefixes. XSD is used for example more by Microsoft schemas.

    The important is how you declare the namespace.

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"></xs:schema>
    

    or

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"></xsd:schema>
    

    should be equivalent.

syntax error: Expected end of line but found unknown token.

Hi Everyone:

I am attempting to run some AppleScript in the terminal, just to learn how to do it, and I am running into some trouble with the & sign. Even when the & is replaced with the "&", it still returns the same error.. I have narrowed it down to the problem with the & sign, and am wondering if anyone has any advice about it. I am getting the following error:

syntax error: Expected expression but found unknown token.

My code that I type into the terminal:

osascript -e 'tell application "Finder"' -e 'set location to (path to home folder as string) & \"testing.plist\"' -e 'if (exists file location) then' -e 'say location' -e 'end if' -e 'end tell'

Thanks for any help.

From stackoverflow
  • You don't need the backslashes to escape the double quotes for "testing.plist", removing those will fix that error.

    Additionally, the word "location" is used by the Finder dictionary, so you'll want to use some other term for that variable, such as "myLocation" instead.

    PF1 : Hi Brian: Thanks for your advice. It fixed my problem.

iframe auto resize

I have been desperatly searching the web for a way to auto resize an iframe. I have tried many scripts online, but most recieve a permission denied error.

Both sites are members of the same subdomain

site 1: (views iframe) sub.domain.site.ca site 2: name.site.ca

how is this done (both are members of 'site.ca')

From stackoverflow

Most efficient way to add attribute to begining of massive XML file in Java?

What is the fastest way to add an attribute to the root element of a massive XML file? These files are too large to be read into memory and I'd like to avoid as much of an I/O penalty as possible.

From stackoverflow
  • Aren't you going to have to rewrite the entire file anyway if you're inserting text at or near the beginning? A SAX parser should be adaptable to buffer input (via an InputStream) if you don't want it all in memory at once.

    You'll still take the hit of rewriting the entire file but not the memory hit of having it in memory at once. Basically you'll be parsing the file, listening to the SAX events and writing out the new file from those events. Your SAX parser will then also listen for the right circumstances to add an attribute.

    bruno conde : Excellent answer :)
  • It's virtually impossible not to rewrite the file in Java (I don't even think you could do this if you were tweaking the files at the system level, but maybe...)--So your question becomes what's the most efficient way to rewrite the file?

    If possible, I'd avoid all the XML parsers and write my own. This would require that you can easily identify where in the file this new attribute needs to go. If you can come up with the string to match it, you can read in a little at a time, scan for the insertion point and just insert your extra data when you get there, then keep copying the rest over.

Do you perform any validation on the OpenID URI?

When you are logging in a user using OpenID, do you perform any validation on the OpenID URI (or identifier)? Or do you just let the library handle it (like DotNetOpenAuth).

From stackoverflow
  • DotNetOpenAuth handles all validation. Web sites that add validation are likely to needlessly break some OpenIDs (for example, when XRI support was added, those don't look like URLs, and a web site that tried to make it look like a URL would break XRIs).

Win32: Monitoring for files being created or changed

1) How can I use FindFirstChangeNotification / FindNextChangeNotification + ReadDirectoryChanges to detect certain files being created or removed?

2) Is the FILE_NOTIFY_CHANGE_LAST_WRITE a reliable indicator of a file change?


Application: I have an explicit list of files that may be located in different folders. Display contents depends on the first file in the lsit that actually exists. For this, I want to add an auto-refresh mechanism.

Thus I need to detect "more important" files being created, the current file being changed or removed.

The list isn't long (maybe a dozen or so files), so I could poll the files, but for some applications the polling interval should be 50..80ms, ad I wonder if the monitoring API's are a better choice.

Response times should not exceed 200ms (not including any stalls due to unresponsive disks or high system load), but under ideal conditions, update should appear "immediate" to a human operator, without incurring high system load.

From stackoverflow
  • The monitoring functions are a much better and cleanerr solution than polling, which itself would affect performance. But your response times cannot be guaranteed - Windows is not an RTS.

SVN: locally ignore files when updating

Hi, I would like to delete/change some file in my local SVN repository and then SVN not to try update them while doing update (just for me on my local machine). I have to test one specific bug with this customers data, but it 12GB of them. So I would like to exchange some of DB file with dummy (empty with correct structure (MDB)) files. And I want SVN to ignore these files while doing updates (especially not to bother me with conflicts).

Is this possible?

Thx, Milan

From stackoverflow
  • You must add the file to the parent directory's svn:ignore property. If you're using tortoisesvn there should be a menu option to "Add to ignore list" or something similar. documentation link: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-ignore.html

    sbi : But that's nit just locally.
  • This is not possible. However, you can selectively update all other files.

    rezna : i know i can do it selectively - but this is quite anoying :/ - anyway thx - i was just checking if i'm right and that it's not possible

MySQL query - show results that are not in another table

I have a query like this:

SELECT lesson.id, p1.first_name, p1.surname, start_time, instrument.name 
FROM  lesson, person AS p1, person AS p2, instrument, invoice_lesson
WHERE lesson.student = p1.id
AND   lesson.teacher = p2.id
AND   instrument.id  = lesson.instrument_id
ORDER BY surname

However, I would like to modify it so that it only shows results where lesson.id is not in the table invoice_lesson.lesson_id. Is this a correlated query? How do I do this?

From stackoverflow
  • The easiest way:

    SELECT lesson.id, p1.first_name, p1.surname, start_time, instrument.name 
    FROM  lesson, person AS p1, person AS p2, instrument, invoice_lesson
    WHERE lesson.student = p1.id
    AND   lesson.teacher = p2.id
    AND   instrument.id  = lesson.instrument_id
    AND   lesson.id NOT IN (SELECT lesson_id FROM invoice_lesson)
    ORDER BY surname
    

    Might not exactly be the quickest one :)

    Tomasz Kopczuk

    thedz : You really should be using a join, rather than a sub select.
  • You can do this with an outer join:

    SELECT lesson.id, p1.first_name, p1.surname, start_time, instrument.name 
    FROM  lesson l JOIN person p1 ON l.student = p1.id
    JOIN person p2 ON l.teacher = p2.id
    JOIN instrument i ON i.id = l.instrument_id
    LEFT JOIN invoice_lesson il ON l.id = il.lesson_id
    WHERE il.lesson_id IS NULL
    ORDER BY surname
    

    This approach will be much faster than the correlated subquery approach.

    Robert : the first line needed altering to match you aliases though ;) thx
  • Try using a JOIN:

     SELECT lesson.id, p1.first_name, p1.surname, start_time, instrument.name 
     FROM  lesson, person AS p1, person AS p2, instrument, invoice_lesson
     JOIN  invoice_lesson
     ON    lession.id = invoice_lession.lesson_id
     WHERE lesson.student = p1.id
     AND   lesson.teacher = p2.id
     AND   instrument.id  = lesson.instrument_id
     ORDER BY surname
    
    Robert : Syntax error or access violation: 1066 Not unique table/alias: 'invoice_lesson'

Django python path with Apache and mod_python

I'm trying to set up Review Board, which uses Django, on WinXP with Apache 2.2 and mod-python.

I have a default Python install, but I want to use a different instance. The default is c:/python25, but I want d:/xxx/python25. mod-python has a config option to change the path, but I don't want to have to recompile mod_python (as the code is in VCS and could be put anywhere). How can I fix this?

Currently I'm trying to change the environment path using SetEnv in the Apache conf file, e.g.

SetEnv PATH "d:/xxx/python25;PATH"
LoadModule python_module modules/mod_python.so

I.e. setting the environment variable before mod-python is loaded as this is where it finds the Python interpretter.

This doesn't seem to work. Is the syntax wrong? Is there another solution?

Thanks.

From stackoverflow
  • If you're on windows, it's possible it's referencing the registry for the path. Try looking in the registry under:

    HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5

    In particular, the subkeys, InstallPath, Modules, and PythonPath.

    Nick : I guess this is all I can do bar recompile mod_python, which I want to avoid. I think Python and the Review Board dependencies will have to be installed rather than got from VCS. Not a big problem since only need one instance of RB really.

How do I replace tabs with spaces within variables in PHP?

$data contains tabs, leading spaces and multiple spaces, i wish to replace all tabs with a space. multiple spaces with one single space, and remove leading spaces.

in fact somthing that would turn

Input data:
[    asdf asdf     asdf           asdf   ]

Into output data:
[asdf asdf asdf asdf]

How do i do this?

From stackoverflow
  • $data = trim(preg_replace('/\s+/g', '', $data));
    
    Matthew Scharley : You also forgot to mention trim to get rid of leading spaces. Probably want to mention ltrim too, since he asked for leading spaces then illustrated both ends.
    RaYell : Yeah, thanks for pointing that. In the example it's shown that both leading and trailing spaces should be removed so I updated my code.
  • $data = trim($data);
    

    That gets rid of your leading (and trailing) spaces.

    $pattern = '/\s+/';
    $data = preg_replace($pattern, ' ', $data);
    

    That turns any collection of one or more spaces into just one space.

    $data = str_replace("\t", " ", $data);
    

    That gets rid of your tabs.

  • Assuming the square brackets aren't part of the string and you're just using them for illustrative purposes, then:

    $new_string = trim(preg_replace('!\s+!', ' ', $old_string));
    

    You might be able to do that with a single regex but it'll be a fairly complicated regex. The above is much more straightforward.

    Note: I'm also assuming you don't want to replace "AB\t\tCD" (\t is a tab) with "AB CD".

  • $new_data = preg_replace("/[\t\s]+/", " ", trim($data));
    
  • Trim, replace tabs and extra spaces with single spaces:

    $data = preg_replace('/[ ]{2,}|[\t]/', ' ', trim($data));
    

Layout issue with website when in compatibility mode

I noticed the layout of a website is all jacked up when viewing in IE8 in compatibility mode (assuming this means IE7 and/or IE6 as well) compared to viewing it in IE8 and Firefox. Since the site renders fine in IE8 and Firefox, I'm guessing that means I need to override certain styles for IE6/IE7. Are there any tools that I can use like Firebug in FireFox to analyze what CSS settings are jacked up in IE?

The website is [link redacted per request of site owner]...

Any ideas as to what settings should specifically be targeted here?

EDIT
Just found the developer tools in IE8... I've noticed that this CSS setting appears to be the culprit, but I'm not sure why. ".three-columns" is the name of the class being applied to the bottom part of the website.

HTML > BODY .three-columns
{
   height: auto;
}
From stackoverflow

What's the difference between Databinder.Eval and Container.DataItem?

When you're using asp.net databinding expressions:

<asp:Label Text='EXPRESSION' runat="server" />

What's the difference among:

Container.DataItem("Property")

and

Databinder.Eval(Container.DataItem, "Property")

and

Eval("Property")

and

Bind("Property")
From stackoverflow
  • Eval is one-way binding and Bind is for two way binding. Using Eval allows you to get the content into your page, but ASP.Net will not be able to put it back into an object for you.

    The Eval method is just shorthand for DataBinder.Eval. Also, Container.DataItem("Property") is effectively the same as the Eval method except for when you want to return the value of a "path". For instance you can call eval with a dot seperated "path" to a public property that you want the value of, but I do not believe you can do this with Container.DataItem("Property")

Where is a sample of some Javascript code for Location Aware Browsing in Firefox 3.5?

Does anyone know where I can find an example of some javascript code for the new location-aware features of Firefox 3.5?

From stackoverflow

Best Book for Amazon AWS use and load balancing?

Hi All,

Do you know any great book about Amazon Web Services and how to exploit it the best way to do load balancing?

Many thanks for any help,

Best,

Raphael

From stackoverflow

In Composite WPF (Prism), can/should multiple modules share a 'toolbar' region?

I'm very new to Composite WPF and I'm struggling with the basic architecture of the shell.

Assume I have a Shell with three regions - 'OutlookStyleNav', 'Main' and 'Toolbar'.

How do I add buttons to the toolbar region?

Should each module add it's own button(s) to this region? (and if so, how to display all modules' buttons at the same time?)

Should the Shell dynamically detect Commands in my Controllers and create buttons based on that?

I'm not sure. Any suggestions?

From stackoverflow
  • In our current project the modules publish all the available toolbar and menu actions and the toolbar subscribes to these "ActionAvailable" events. The events carry a delegate (which has to be called when the toolbar button is pressed), an action description (= tooltip text), an icon etc.

    This way neither the shell has a direct dependency on the modules nor the modules have a dependency on the shell.

    willem : Good advice. I went a slightly different route... I built a ShellController (and obviously an IShellController interface). The interface gets injected into the modules. The modules then register their toolbar buttons using an IShellController.RegisterToolbar(ICommand command) command. Not as loosely coupled as your implementation though.

Can eclipse prevent you from using particular classes?

For example,

  1. I don't want to use org.testng.v6.Maps, (I want com.google.common.collect.Maps)
  2. I don't want to use org.hibernate.mapping.List, (I want java.util.List like everyone else!)

Is there a way to tell Eclipse not to suggest these in the autocomplete box?

From stackoverflow
  • Re-arrange your dependencies in the library path according to the order you want them to be.

    • Right click on project > Properties
    • Java Build Path
    • Order and Export tab

    This should give priority to the dependencies you do prefer. (Although on second thought I am not sure this is reflected in the auto-complete boxes.)

  • Yup - I have exactly this problem at work for a few classes too.

    Preferences -> Java -> Appearance -> Type Filters.