Daily Archives

Articles indexed Sunday March 21 2010

Page 4/85 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Is this the 'Pythonic' way of doing things?

    - by Sergio Tapia
    This is my first effort on solving the exercise. I gotta say, I'm kind of liking Python. :D # D. verbing # Given a string, if its length is at least 3, # add 'ing' to its end. # Unless it already ends in 'ing', in which case # add 'ly' instead. # If the string length is less than 3, leave it unchanged. # Return the resulting string. def verbing(s): if len(s) >= 3: if s[-3:] == "ing": s += "ly" else: s += "ing" return s else: return s # +++your code here+++ return What do you think I could improve on here?

    Read the article

  • TableView with section & Index

    - by iavian
    could anyone point me to some examples on how to achieve Tableview with section and Index on Section. Similar to one it's in iPhone = http://www.iphonesdkarticles.com/2009/01/uitableview-indexed-table-view.html

    Read the article

  • Want to improve my simple site/db backup script with auto removal of old backups.

    - by Robert Robb
    I have the following simple script for backing up my website files and db. The script is run each day via a cron job. #!/bin/sh NOW=$(date +"%Y-%m-%d") mysqldump --opt -h localhost -u username -p'password' dbname > /path/to/folder/backup/db-backup-$NOW.sql gzip -f /path/to/folder/backup/db-backup-$NOW.sql tar czf /path/to/folder/backup/web-backup-$NOW.tgz /path/to/folder/web/content/ It works great, but I don't want loads of old backups clogging my system. How can I modify the script to remove any backups older than a week when the script is run?

    Read the article

  • Is generic Money<T_amount> a good idea?

    - by jdk
    I have a Money Type that allows math operations and is sensitive to exchange rates so it will reduce one currency to another if rate is available to calculate in a given currency, rounds by various methods. It has other features that are sensitive to money, but I need to ask if the basic data type used should be made generic in nature. I've realized that the basic data type to hold an amount may differ for financial situations, for example: retail money might be expressed as all cents using int or long where fractions of cents do not matter, decimal is commonly used for its fixed behaviour, sometimes double seems to be used for big finance and large values sometimes a special BigInteger or 3rd-party type is used. I want to know if it would be considered good form to turn Money into Money<T_amount> so it can be used in any one of the above chosen scenarios?

    Read the article

  • Validation plugin hijacks click function?

    - by timkl
    Absolute newbie question, any help is highly appreciated :) I am using curvycorners (http://www.curvycorners.net/) in combination with the jQuery validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/), and I'm having problems getting the div to redraw the rounded corners when I do like this: $("input[type='submit']").click(function(e) { curvyCorners.redraw(); }); When I click the submit-button the first time the form validates, the validation error-message pops up and expands the div, causing the layout to go ugly. However when I click on it the second time the rounded corners redraw nicely. Could it be that my validation plugin hijacks my initial click? How do I go about this? Any hint is very much appreciated.

    Read the article

  • How to map IDictionary<string, object> in Fluent NHibernate?

    - by user298221
    I am looking to persist user preferences into a collection of name value pairs, where the value may be an int, bool, or string. There are a few ways to skin this cat, but the most convenient method I can think of is something like this: public class User { public virtual IDictionary<string, object> Preferences { get; set; } } with its usage as: user.Preferences["preference1"] = "some value"; user.Preferences["preference2"] = 10; user.Preferences["preference3"] = true; var pref = (int)user.Preferences["preference2"]; I'm not sure how to map this in Fluent NHibernate, though I do think it is possible. Generally, you would map a simpler Dictionary<string, string> as: HasMany(x => x.Preferences) .Table("Preferences") .AsMap("preferenceName") .Element("preferenceValue"); But with a type of 'object', NHibernate doesn't know how to deal with it. I imagine a custom UserType could be created that breaks an 'object' down to a string representing its Type and a string representing the value. We would have a table that looks kind of like this: Table Preferences userId (int) preferenceName (varchar) preferenceValue (varchar) preferenceValueType (varchar) and the hibernate mapping would like this: <map name="Preferences" table="Preferences"> <key column="userId"></key> <index column="preferenceName" type="String" /> <element type="ObjectAsStringUserType, Assembly"> <column name="preferenceValue" /> <column name="preferenceValueType"/> </element> </map> I'm not sure how you would map this in Fluent NHibernate. Maybe there's a better way to do this, or maybe I should just suck it up and use IDictionary<string, string>. Any ideas?

    Read the article

  • Lotus NotesSQL Driver - cannot install

    - by PowerUser
    Hi all, I need to install Lotus NotesSQL Driver (current version is 8.5) onto a virtual machine running XP. Here's what's I've done so far: I retrieved the file (CZOWFEN.zip) from the IBM website. I ran the exe. I then went to My Computer-Properties-Advanced-Environmental Settings-System Variables-Path and added "; c:\notessql" so the ODBC administrator could find Notes.ini (why the setup file didn't do this in the first place, i don't know). I opened up the ODBC administrator and tried to add a new System DSN to a Lotus DB. "The setup routines for the Lotus Notes SQL Driver (*.nsf) ODBC driver could not be loaded due to system error code 126" I redownloaded and reinstalled the driver (making sure I had the latest version 8.5). No luck. I checked the registry. All the file paths appeared to be correct. Per many, many similar cases on the internet, I tried several different variations of adding the various Lotus Notes folders to my PATH variables. Same error. I've done this setup on 5 different machines now with no problem. The only difference here is that this machine is virtual. Ideas?

    Read the article

  • How to re-join an AD2003 domain with Samba after deleting the machine account?

    - by Guss
    During some troubleshooting I deleted the machine account for a Linux server running samba from our AD 2003 domain. We are using Kerberos for authentication, and after I deleted the machine account I tried to join the domain again using net ads join -U Administrator But I keep getting Kerberos errors like these: [2009/08/18 16:14:36, 0] libads/kerberos.c:ads_kinit_password(228) kerberos_kinit_password [email protected] failed: Client not found in Kerberos database Failed to join domain: Improperly formed account name It appears as if samba remembers that it once had an account with the AD and keeps trying to reconnect to it, but I want to create a new account from scratch. I tried to delete all the .tdb files I could find as well as everything under /var/cache/samba but to no avail - it still behaves the same. I also tried to create the machine account on the AD side, but then I get a similar error when I try to join, about failure to authenticate with the machine account - it looks like samba tries the previous machine account password and I don't know how to reset it, or even if I could figure out what samba uses - how to set it in the AD. Any help would be greatly appreciated, as at this point the only thing I can think about is to reformat and reinstall the machine, and I would really REALLY love to not do that. Thanks in advance.

    Read the article

  • Using a hypercard file on a Windows machine

    - by ajma
    Hello, my parents were cleaning out their house and found an old Mac Classic which I used a long time ago to run HyperCard. I made a couple things which I'd like to keep but I don't know what appliations will even run Hypercard files anymore. Also, I'm using a Windows computer now. Can anyone recommend an emulator or some way to convert it to something I can use on my Windows machine?

    Read the article

  • Extra Volumes appearing after using MyDefrag

    - by user17381
    Hi, After using MyDefrag, when I start the defrag again, two new drives have appeared - with very odd names. They are both named the same thing: \\?\Volume{WhatLooksLikeAGUID} Note the Guid (and hence the drive names) are both the same - any idea whats going on here? Thanks. OS: Windows XP Pro SP2.

    Read the article

  • How to replace all instances of a particular value in a mysql database with another?

    - by Joseph
    I'm looking for a MySQL equivalent of what str_replace is for PHP. I want to replace all instances of one word with another, I want to run a query that will replace all "apples" with "oranges". The reason why: UPDATE fruits SET name='oranges' WHERE name='apples'; isn't going to work for my situation, is because I often times have multiple words in a table row separated by commas like: "apples, pears, pineapples". In this case I want just apples to be replaced by oranges and pear and pineapples to stay in tact. Is there any way to do this?

    Read the article

  • Pythonic way of adding "ly" to end of string if it ends in "ing"?

    - by Sergio Tapia
    This is my first effort on solving the exercise. I gotta say, I'm kind of liking Python. :D # D. verbing # Given a string, if its length is at least 3, # add 'ing' to its end. # Unless it already ends in 'ing', in which case # add 'ly' instead. # If the string length is less than 3, leave it unchanged. # Return the resulting string. def verbing(s): if len(s) >= 3: if s[-3:] == "ing": s += "ly" else: s += "ing" return s else: return s # +++your code here+++ return What do you think I could improve on here?

    Read the article

  • Why does the the Java VM not recover after "Too many open files" errors?

    - by Michael
    In certain well-understood circumstances, our application will open too many sockets (database connections) and reach the maximum open files that the OS allows. We understand this; we are fixing the issue and also bumping up the limit. What we can't explain is why parts of our application don't recover even after the number of connections abates and we're well within the limit. In this case, it's an application running under Tomcat. When this happens, we first start seeing "Too many open files" errors: SEVERE: Socket accept failed java.net.SocketException: Too many open files at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:390) at java.net.ServerSocket.implAccept(ServerSocket.java:453) at java.net.ServerSocket.accept(ServerSocket.java:421) at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61) at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:310) at java.lang.Thread.run(Thread.java:619) Eventually, we start seeing NoClassDefFoundErrors inside an application thread that's trying to open HTTP connections: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:128) at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1349) [...] Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 8 more When the errant connections go away, the server starts accepting connections again, and everything seems ok, but we're left with the latter error constantly being spewed to stderr. Although the application typically logs unloaded classes to stdout, I don't see any such logs just before, during or after the "Too many open files" errors. My initial theory was that the Hotspot JVM would unload seemingly unused classes when it encounters "Too many open files," but if so, it doesn't log the fact. I'd also expect it to recover if that were the case. Platform details: Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode) Apache Tomcat Version 6.0.18

    Read the article

  • Exactly clone an object in javascript

    - by Tom
    Hi, I tried to exactly clone an object in javascript. I know the following solution using jquery: var newObject = jQuery.extend({}, oldObject); // Or var newObject = jQuery.extend(true, {}, oldObject); but the problem with that is, that the objects type gets lost: var MyClass = function(param1, param2) { alert(param1.a + param2.a); }; var myObj = new MyClass({a: 1},{a: 2}); var myObjClone = jQuery.extend(true, {}, myObj); alert(myObj instanceof MyClass); // => true alert(myObjClone instanceof MyClass); // => false Is there any solution to get true on the second alert?

    Read the article

  • Program for HID USB Scale

    - by Alex
    Hi guys, I'm looking for a program that can read the weight on a USB scale, namely the Pelouze 10lb USB Portable Scale. I thought it would have a virtual COM port driver but instead, it uses HID drivers. I've been searching for a whole month for a program that can help me transfer the reading of the scale to Microsoft Excel. Can someone help me out or point me in the right direction? I am absolutely illiterate to programming. Much gratitude any help given.

    Read the article

  • PageMethods security

    - by TenaciousImpy
    Hi, I'm trying to 'AJAX-ify' my site in order to improve the UI experience. In terms of performance, I'm also trying to get rid of the UpdatePanel. I've come across a great article over at Encosia showing a way of posting using PageMethods. My question is, how secure are page methods in a production environment? Being public, can anyone create a JSON script to POST directly to the server, or are there cross-domain checks taking place? My PageMethods would also write the data into the database (after filtering). I'm using Forms Authentication in my pages and, on page load, it redirects unauthenticated users to the login page. Would the Page Methods on this page also need to check authentication if the user POSTs directly to the method, or is that authentication inherited for the entire page? (Essentially, does the entire page cycle occur even if a user has managed to post only to the PageMethod)? Thanks

    Read the article

  • Install mod_jk with Apache 2.2

    - by peter
    I have downloaded mod_jk-1.2.28-httpd-2.2.X.so for Apache 2.2 running on CentOS, and set up as per http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html. When I try to start httpd it fails with the following error: "Starting httpd: httpd: Syntax error on line 993 of /etc/httpd/conf/httpd.conf: Syntax error on line 2 of /opt/apache-tomcat-6.0.26/conf/jk/mod_jk.conf-auto: Cannot load /etc/httpd/modules/mod_jk-1.2.28-httpd-2.2.X.so into server: /etc/httpd/modules/mod_jk-1.2.28-httpd-2.2.X.so: wrong ELF class: ELFCLASS32" Does that mean that mod_jk-1.2.28-httpd-2.2.X.so has not been properly compiled?. What can I do about that? Thanks Peter

    Read the article

  • How can I change the user identity that runs a build agent in TeamCity?

    - by Chris Farmer
    I am trying to get a build process set up in TeamCity 5, and I am encountering an access denied error when trying to copy some files. I see that my build agent is running as "SYSTEM" now, and I think that's part of the problem. I'd like to change that user identity. The trouble is that I can't figure out how to change those settings on the build agent. How can I change the build user identity?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >