Daily Archives

Articles indexed Tuesday March 9 2010

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

  • Handling newline character in input between Windows and Linux

    - by Fazal
    I think this is a standard problem which may have been asked before but I could not get the exact answer so posting the issue. The issue is that our server is running on a linux box. We access the server over the browser on a window box to enter data into field which is supposed to contain multiple lines which user can enter by pressing the enter key after each line Abc Def GHI When this input field (this is a text area),is read on the linux machine, we want to split the data based on new line character. I had three question on this. Does the incoming data contain "\r\n" or "\n" If incoming data does contain "\r\n", the linux line.separator property (vm property) would not work for me as it would say "\n" and therefore may leave "\r" in the data. If "\r" is left in the data, if I open the file on a windows machine, will this mean a newline character? Finally can anyone tell me the standard way to deal with this issue?

    Read the article

  • Does EOF actually exist?

    - by terrani
    Hi, When I use file functions in PHP, I check for EOF. I wonder if EOF actually exist in a file. When I create an empty text file, it displays 0KB. How does EOF exist in a file with 0KB?

    Read the article

  • Redirect folder to different server

    - by yuval
    I know you can redirect subdomains to a different server, but can you do the same with folders? Say I have example.com. I can redirect mysubdomain.example.com to a different server, but can I redirect example.com/mysubdomain to a different server? I'd like to host a rails app in that folder on a site that runs php while still maintaining good search engines ratings (by not creating a sub domain which in my experience in recognized as a different site). Any help? Thanks!

    Read the article

  • C++ input chaining in C#

    - by Monty
    I am trying to learn C# coming from C++. I am writing just some basic console stuff to get a feel for it and was wondering if it is possible to do simple chaining of inputs in C#. For example in C++: cout<<"Enter two numbers: "; cin >> int1 >> int2; You could then just input 3 5 and hit enter and the values will be fine. In C# however I have to split it up(as far as I can tell) like this: Console.Write("Enter the first number: "; int1 = (char)Console.Read(); Console.Writeline(""); Console.Write("Enter the second number: "; int2 = (char)Console.Read(); Maybe I am just missing something.

    Read the article

  • ASP.NET Excel Export formatting question

    - by BWC
    Hey Guys, I've been banging my head on the wall over this issue for a couple days now and I need some help. I'm creating an excel file using ASP.net and everything is going just fine except one column has to be formatted as a decimal to 2 places but when it pulls into excel, excel automatically formats it as a whole number instead of keeping the decimal places. sw.Write(String.Format("{0:f}", CDbl(dr(14)).ToString("0.00"))) this produces "20.00" but when I open it in excel it's displayed as 20...if I select the whole column and format it as a number it gets displayed as 20.00 like it's supposed to but I don't want to have to do this (I can't do that) the file is supposed to be automatically picked up and imported into another system that needs the column to be a decimal. Any suggestions would be greatly appreciated.

    Read the article

  • Windows 7 wireless not seeing any networks

    - by jkohlhepp
    I think I have managed to confuse Windows 7. When I did the install, I had the network cable plugged in to my router, but the wireless card was also enabled. During the install, Windows 7 seemed to see my wireless network and even asked me for the WEP key. I know that it used the WEP key because I initially entered an invalid one and it gave me an error. Then the network said "SoAndSoWireless Connected". However, when I unplug or disable my wired network card, then I have no internet, and it can't see any networks. When I plug in the wired network card, it says "SoAndSoWireless Connected". Under Network and Internet Network Connections I have "Local Area Connection" and "Wireless Network Connection". The wired one's status is "SoAndSoWireless" and the wireless status is "Not Connected". Also, the wireless connection can't seem to see any other wireless networks in the area and I know there are tons. My neighbors have several. I've somehow seemingly confused Windows 7 into thinking that my wired network card is my wireless card or something. Any ideas on how to un-confuse it? This is a desktop machine by the way, if it matters. EDIT: Ah, I think part of the problem is that I named my network accidentally the same as the name of the wireless network being broadcast by the wireless router. So that might be why it says that name on the hard-wired connection. Perhaps the drivers just are completely not working for the wireless card. Thanks, ~ Justin

    Read the article

  • Do you have health checks in your web app or web site?

    - by Pekka
    I have built PHP based "health check" scripts for several projects, but they were always custom-made for the occasion and not written for abstraction as an independent product. I would like to know whether such a solution exists. What I meam by "health check" is a protected web page that functions much like a suite of unit tests, but on a more operational level, showing red/yellow/green statuses for things like Are the cache directories writable? Is the PHP version correct, are required extensions installed? Is the configuration file protected from writing? Is the database server reachable? Do the key tables exist in the database? Is there enough disk space available? Is the site's front page reachable and renders fully ( = no PHP errors)? Do the project's libraries' MD5 checksums match the original ones? Do you do this - or parts of it - in your applications and web sites? Are there any standardized tools for this that bring along all the functionality to perform the tests (ideally as plugins), and just need to be configured accordingly? Is there a way to set this up using one of the Unit Testing frameworks available for PHP (preferably PHPUnit)? If so, do you know any resources / tutorials outlining how?

    Read the article

  • Temporary non-const istream reference in constructor (C++)

    - by Christopher Bruns
    It seems that a constructor that takes a non-const reference to an istream cannot be constructed with a temporary value in C++. #include <iostream> #include <sstream> using namespace std; class Bar { public: explicit Bar(std::istream& is) {} }; int main() { istringstream stream1("bar1"); Bar bar1(stream1); // OK on all platforms // compile error on linux, Mac gcc; OK on Windows MSVC Bar bar2(istringstream("bar2")); return 0; } This compiles fine with MSVC, but not with gcc. Using gcc I get a compile error: g++ test.cpp -o test test.cpp: In function ‘int main()’: test.cpp:18: error: no matching function for call to ‘Bar::Bar(std::istringstream)’ test.cpp:9: note: candidates are: Bar::Bar(std::istream&) test.cpp:7: note: Bar::Bar(const Bar&) Is there something philosophically wrong with the second way (bar2) of constructing a Bar object? It looks nicer to me, and does not require that stream1 variable that is only needed for a moment.

    Read the article

  • Easy to use time-stamps in Python

    - by Morlock
    I'm working on a journal-type application in Python. The application basically permits the user write entries in the journal and adds a time-stamp for later querying the journal. As of now, I use the time.ctime() function to generate time-stamps that are visually friendly. The journal entries thus look like: Thu Jan 21 19:59:47 2010 Did something Thu Jan 21 20:01:07 2010 Did something else Now, I would like to be able to use these time-stamps to do some searching/querying. I need to be able to search, for example, for "2010", or "feb 2010", or "23 feb 2010". My questions are: 1) What time module(s) should I use: time vs datetime? 2) What would be an appropriate way of creating and using the time-stamp objects? Many thanks!

    Read the article

  • Django: Overriding the clean() method in forms - question about raising errors

    - by Monika Sulik
    I've been doing things like this in the clean method: if self.cleaned_data['type'].organized_by != self.cleaned_data['organized_by']: raise forms.ValidationError('The type and organization do not match.') if self.cleaned_data['start'] > self.cleaned_data['end']: raise forms.ValidationError('The start date cannot be later than the end date.') But then that means that the form can only raise one of these errors at a time. Is there a way for the form to raise both of these errors? EDIT #1: Any solutions for the above are great, but would love something that would also work in a scenario like: if self.cleaned_data['type'].organized_by != self.cleaned_data['organized_by']: raise forms.ValidationError('The type and organization do not match.') if self.cleaned_data['start'] > self.cleaned_data['end']: raise forms.ValidationError('The start date cannot be later than the end date.') super(FooAddForm, self).clean() Where FooAddForm is a ModelForm and has unique constraints that might also cause errors. If anyone knows of something like that, that would be great...

    Read the article

  • Processing a log to fix a malformed IP address ?.?.?.x

    - by skymook
    I would like to replace the first character 'x' with the number '7' on every line of a log file using a shell script. Example of the log file: 216.129.119.x [01/Mar/2010:00:25:20 +0100] "GET /etc/.... 74.131.77.x [01/Mar/2010:00:25:37 +0100] "GET /etc/.... 222.168.17.x [01/Mar/2010:00:27:10 +0100] "GET /etc/.... My humble beginnings... #!/bin/bash echo Starting script... cd /Users/me/logs/ gzip -d /Users/me/logs/access.log.gz echo Files unzipped... echo I'm totally lost here to process the log file and save it back to hd... exit 0 Why is the log file IP malformed like this? My web provider (1and1) has decide not to store IP address, so they have replaced the last number with the character 'x'. They told me it was a new requirement by 'law'. I personally think that is bs, but that would take us off topic. I want to process these log files with AWstats, so I need an IP address that is not malformed. I want to replace the x with a 7, like so: 216.129.119.7 [01/Mar/2010:00:25:20 +0100] "GET /etc/.... 74.131.77.7 [01/Mar/2010:00:25:37 +0100] "GET /etc/.... 222.168.17.7 [01/Mar/2010:00:27:10 +0100] "GET /etc/.... Not perfect I know, but least I can process the files, and I can still gain a lot of useful information like country, number of visitors, etc. The log files are 200MB each, so I thought that a shell script is the way to go because I can do that rapidly on my Macbook Pro locally. Unfortunately, I know very little about shell scripting, and my javascript skills are not going to cut it this time. I appreciate your help.

    Read the article

  • jquery: validate that text field is numeric

    - by George Johnston
    I have simple issue -- I would like to check a field to see if it's numeric if it is not blank. I'm not using any additional plugins, just jQuery. My code is as follows: if($('#Field').val() != "") { if($('#Field').val().match('^(0|[1-9][0-9]*)$')) { errors+= "Field must be numeric.<br/>"; success = false; } } ...It doesn't seem to work. Where am I going wrong? Thanks, George

    Read the article

  • Classes, methods, and polymorphism in Python

    - by Morlock
    I made a module prototype for building complex timer schedules in python. The classe prototypes permit to have Timer objects, each with their waiting times, Repeat objects that group Timer and other Repeat objects, and a Schedule class, just for holding a whole construction or Timers and Repeat instances. The construction can be as complex as needed and needs to be flexible. Each of these three classes has a .run() method, permitting to go through the whole schedule. Whatever the Class, the .run() method either runs a timer, a repeat group for a certain number of iterations, or a schedule. Is this polymorphism-oriented approach sound or silly? What are other appropriate approaches I should consider to build such a versatile utility that permits to put all building blocks together in as complex a way as desired with simplicity? Thanks! Here is the module code: ##################### ## Importing modules from time import time, sleep ##################### ## Class definitions class Timer: """ Timer object with duration. """ def __init__(self, duration): self.duration = duration def run(self): print "Waiting for %i seconds" % self.duration wait(self.duration) chime() class Repeat: """ Repeat grouped objects for a certain number of repetitions. """ def __init__(self, objects=[], rep=1): self.rep = rep self.objects = objects def run(self): print "Repeating group for %i times" % self.rep for i in xrange(self.rep): for group in self.objects: group.run() class Schedule: """ Groups of timers and repetitions. Maybe redundant with class Repeat. """ def __init__(self, schedule=[]): self.schedule = schedule def run(self): for group in self.schedule: group.run() ######################## ## Function definitions def wait(duration): """ Wait a certain number of seconds. """ time_end = time() + float(duration) #uncoment for minutes# * 60 time_diff = time_end - time() while time_diff > 0: sleep(1) time_diff = time_end - time() def chime(): print "Ding!"

    Read the article

  • use of EntityManagerFactory causing duplicate primary key exceptions

    - by bradd
    Hey guys, my goal is create an EntityManager using properties dependent on which database is in use. I've seen something like this done in all my Google searches(I made the code more basic for the purpose of this question): @PersistenceUnit private EntityManagerFactory emf; private EntityManager em; private Properties props; @PostConstruct public void createEntityManager(){ //if oracle set oracle properties else set postgres properties emf = Persistence.createEntityManagerFactory("app-x"); em = emf.createEntityManager(props); } This works and I can load Oracle or Postgres properties successfully and I can Select from either database. HOWEVER, I am running into issues when doing INSERT statements. Whenever an INSERT is done I get a duplicate primary key exception.. every time! Can anyone shed some light on why this may be happening? Thanks -Brad

    Read the article

  • How to map different UI views in a RESTful web application?

    - by MicE
    Hello, I'm designing a web application, which will support both standard UIs (accessed via browsers) and a RESTful API (an XML/JSON-based web service). User agents will be able to differentiate between these by using different values in the Accept HTTP header. The RESTful API will use the following URI structure (example for an "article" resource): GET /article/ - gets a list of articles POST /article/ - adds a new article PUT /article/{id} - updates an existing article based on {id} DELETE /article/{id} - deletes an existing article based on {id} The UI part of the application will however need to support multiple views, for example: a standard resource view a view for submitting a new resource a view for editing an existing resource a view for deleting an existing resource (i.e. display delete confirmation) Note that the latter three views are still accessed via GET, even though they are processed via overloaded POST. Possible solution: Introduce additional parameters (keywords) into URIs which would identify individual views - i.e. on top of the above, the application would support the following URIs (but only for Content-Type: text/html): GET /article/add - displays a form for adding a new article (fetched via GET, processed via POST) GET /article/123 - displays article 123 in "view" mode (fetched via GET) GET /article/123/edit - displays article 123 in "edit" mode (fetched via GET, processed via PUT overloaded as POST) GET /article/123/delete - displays "delete" confirmation for article 123 (fetched via GET, processed via DELETE overloaded as POST) A better implementation of the above might be to put the add/edit/delete keywords into a GET parameter - since they do not change the resource we're working with, it might be better to keep the base URI same for all of them. My question is: How would you map the above URI structure to UIs served to the regular user, considering that there can be several views per each resource, please? Do you agree with the possible solution detailed above, or would you recommend a different approach based on your experience? NB: we've already implemented an application which consists of a standalone RESTful API and a standalone web application. I'm currently looking into options for future projects where these two would be merged together (i.e. in order to reduce overhead). Thank you, M.

    Read the article

  • How does Windows decide which icon format to display when showing an exe's icon in Windows Explorer?

    - by Malcolm
    How does Windows decide which icon format to display when showing an exe's icon in Windows Explorer? Problem: When we look at our icon file and exe with embedded icon file in various Windows Explorer file views, the icon file is displayed in a higher quality mode than the icon displayed for our executable even though the icon in our executable contains the exact same icon. Our exe's icon has jaggier edges which leads me to believe that Windows Explorer may be trying to upsize a lower resolution icon rather than picking an icon appropriate for the actual display size. In a multi-format icon file, is there a specific order we should use for positioning each icon format? For example, we have an icon file with icons in the following formats: - 16x16 - 32x32 - 48x48 - 64x64 - 128x128 - 256x256 We are testing the appearance of our exe's icon using Windows Explorer under Windows XP, Vista and Windows 7. Any suggestions appreciated.

    Read the article

  • Starting Javascript

    - by user288245
    Hi guys, a couple of questions (never done javascript before). Below is part of the what happens on submit, what is something, the action, the php script its sent to? Also is there any software you guys reccomend for checking you're javascript, like the equivalent of an ide? im using notepad++. Is the rest the right sort of idea? I'm using several else ifs for each method, checking valid == true. <SCRIPT LANGUAGE="JavaScript"> <form action="something" onsubmit="return ok()"> function ok() { if (validate_Info() == false) { alert('Please enter a name'); return false; } else if else if

    Read the article

  • How to play sound in Python WITHOUT interrupting music/other sounds from playing

    - by Morlock
    I'm working on a timer in python which sounds a chime when the waiting time is over. I use the following code: from wave import open as wave_open from ossaudiodev import open as oss_open def _play_chime(): """ Play a sound file once. """ sound_file = wave_open('chime.wav','rb') (nc,sw,fr,nf,comptype, compname) = sound_file.getparams( ) dsp = oss_open('/dev/dsp','w') try: from ossaudiodev import AFMT_S16_NE except ImportError: if byteorder == "little": AFMT_S16_NE = ossaudiodev.AFMT_S16_LE else: AFMT_S16_NE = ossaudiodev.AFMT_S16_BE dsp.setparameters(AFMT_S16_NE, nc, fr) data = sound_file.readframes(nf) sound_file.close() dsp.write(data) dsp.close() It works pretty good, unless any other device is already outputing sound. How could I do basically the same (under linux) without having the prerequisite that no sound is being played? If you think the process would require an API to ensure software mixing, please suggest a method :) Thx for the support

    Read the article

  • What code should I put on our softball Jerseys?

    - by jsmith
    I work at a small company full of software Nerds. Our wives have decided to put a Co-Ed softball team together called "The Nerds", rightfully so. One of the wives happens to be a Graphical Designer, she has come up with the brilliant idea to put Code on the Jersey (How this wasn't my idea, I have no clue). The only rule is, she wants Nerds to be a part of the code. I've been racking my brain to come up with something clever, but really haven't been able to. So I decided to open it up to my online family. Where better to ask than SO? As a simple reward to whomever gets the best answer, I planned on taking a picture of the team in their Jersey's so the winner can see their result in action.

    Read the article

  • Allowing user to select a UIPickerView row by tapping.

    - by camilo
    Hi. I'm trying to use a UIPicker View with a behavior somehow different of what's usually seen in iPhone code examples. What I want to do is to allow users to scroll through the picker contents, but not to select a picker's row automatically (using the "didSelectRow" method from picker's delegate). Instead, I want to allow the user to touch the center row of the picker, which gets highlighted, and becomes the selection. Is there any way to achieve this? Thanks in advance.

    Read the article

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