Daily Archives

Articles indexed Tuesday April 20 2010

Page 22/121 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Initializing Multidimentional Arrays

    - by Eddy Freeman
    Hi Guy, I have a 3-multidimentional array : int[][][] env; which i would like to initialize with data in a text file. The data in the text file looks like this: { { { 0, 1,-1}, { 0, 2,-1}, {-1,-1,-2}, { 0, 0, 0} }, { { 0, 0,-1}, { 0, 0,-1}, {-1,-1,-2}, { 0, 0, 0} } } Actually the accolades can be removed and replaced with different characters if it is necessary. If there are any better way to format the values in the text file, then it is welcomed. I am looking for the best way to initialize the array in the java program with the values from the text file. All your help is appreciated. Thanks.

    Read the article

  • JQuery and PHP display problem

    - by TheCREATOR
    I'm new to JQuery but for some reason I cant get the php code to display correctly when I put it in my JQuery script. The php code will display correctly when its not in the JQuery code can someone help me fix my JQuery code so it will display my PHP code correctly? Here is the JQuery and PHP code. var count = 0; $(function(){ $('p#add_field').click(function(){ count += 1; $('#container').append( '<input type="text" name="sk" id="sk" />' + '<label for="exp">Exp: </label>' + '<?php' + 'echo \'<select id="exp" name="exp">\' . "\n";' + 'foreach($options as $option) {' + 'if ($option == $exp) {' + 'echo \'<option value="\' . stripslashes(htmlentities(strip_tags($option))) . \'" selected="selected">\' .' + ' stripslashes(htmlentities(strip_tags($option))) . \'</option>\' . "\n";' + '} else {' + 'echo \'<option value="\'. stripslashes(htmlentities(strip_tags($option))) . \'">\' .' + 'stripslashes(htmlentities(strip_tags($option))) . \'</option>\'."\n";' + '}' + '}' + 'echo \'</select>\';' + '?>' + '<label for="g">RGB: </label>' + '<?php' + 'echo \'<select id="g" name="g">\' . "\n";' + 'foreach($options as $option) {' + 'if ($option == $g) {' + 'echo \'<option value="\' . stripslashes(htmlentities(strip_tags($option))) . \'" selected="selected">\' .' + 'stripslashes(htmlentities(strip_tags($option))) . \'</option>\' . "\n";' + '} else {' + 'echo \'<option value="\'. stripslashes(htmlentities(strip_tags($option))) . \'">\' .' + 'stripslashes(htmlentities(strip_tags($option))) . \'</option>\'."\n";' + '}' + '}' + 'echo \'</select>\';' + '?></li>' ); }); });

    Read the article

  • parse XML file that contains unicode characters in iphone

    - by Jim
    Hi, I am trying to parse one XML file that contains some unicode characters.I tried to parse the file using NSXMLParser but i am unable to parse XML.Parser stops when it encounters any unicode characters. Is there any other good solution to parse XML file with unicode letters? Please suggest. Thanks, Jim.

    Read the article

  • How to show error message with jquery tooltip?

    - by bala3569
    I am validating my controls in a form... if a control is empty i would like to show a jquery tooltip with that error msg.. Here is what i am doing... if (document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline") .selectedIndex == -1) { document.getElementById("ctl00_ContentPlaceHolder1_ErrorMsg").innerHTML = "please select your Discipline"; document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline").focus(); return false; } and i would like to do like this, if (document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline") .selectedIndex == -1) { // show tooltip besides the control with the error message... document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline").focus(); return false; } Any suggestion...

    Read the article

  • RichTextBox doesn't update caret position correctly

    - by shadeMe
    I have a handler consuming the keyDown event of a WinForms RTB, that has the following code: GetTextAtLoc(RTB->SelectionStart); // selects some text at the caret's position RTB->SelectedText = "SomeOfMyOwn"; GetTextAtLoc(RTB->SelectionStart); // selects the replacement string RTB->SelectionStart += RTB->SelectionLength - 1; While this code seems to do its job (SelectionStart/Length properties are updated correctly), the caret doesn't move to the end of the new string - It says right where it was at the time of GetTextAtLoc's first call. Redrawing the textbox does seem to have any effect either.

    Read the article

  • After Trigger execute before constraint check in oracle

    - by satakare
    Hi, I have After Insert/Update trigger on Table T1 which get the referential data for Col1 from T2 and does some work and insert it into another table. The col1 is FK to Table T2. When user insert the incorrect or non existing value into the Col1 and if trigger is disabled I am getting constraint error that is fine. But when trigger is enabled and user insert the wrong value in Col1 trigger is getting fired and shows the 'no data found' error message. Actually I am expecting the table to throw constraint error, but trigger is throwing it. Please let me know your comments about this trigger behaviour.

    Read the article

  • jQuery: Returns only part of a text

    - by Warrantica
    I want to write a jQuery function that will return only a part of a given text. For example, in the text: http://somesubdomain.somesite.com/ How can I write a function so that it returns the text "somesubdomain"? In other words, I want to "subtract" the text "http://" and ".somesite.com/". Thanks in advance

    Read the article

  • Excel 2003 - ADDRESS() function issues

    - by hairdresser-101
    I finally thought I had found a way to acutally use excel productively but the code that I followed does not appear to work. I'm thinking that the code is very limited and can't do what I want but I thought I'd ask to confirm - maybe it is my function that is the problem. I want to calculate the sum of a row of values for the previous month based on how many days we are into this month (i.e. It is the 20th of April so I want to sum the first 20 days of March to compare against.) =SUM(G4:ADDRESS(ROW(),7+$BR$3,4)) I basically want to SUM(G4:AA4) and have used the address function to return the cell reference AA4 by taking G4 and adding 20 to the column count. ADDRESS(ROW(),7+$BR$3,4) This successfully returns AA7 as expected HOWEVER, when I try to use the returning value in the SUM() function it throws an error... Am I not able to use this reference in my calculation?

    Read the article

  • Linq2Entities: Update relationship?

    - by Poku
    Hey, How do i create a new row in a table which have a relationship with another table? I have an Employees table and a EmployeeProjects table. One Employee can have 1-* EmployeeProjects. Now i want to create a new EmployeeProject which relates to an Employee. How do i do this? Here is want i have tried so far: var ep = new EmployeeProjects(); ep.JobNo = jobNo; employee.EmployeeProjects.Add(ep); var originalEmployee = GetEmployee(employee.Id); _entities.ApplyPropertyChanges(originalEmployee.EntityKey.EntitySetName, employee); _entities.SaveChanges();

    Read the article

  • Is functional GUI programming possible?

    - by eman
    I've recently caught the FP bug (trying to learn Haskell), and I've been really impressed with what I've seen so far (first-class functions, lazy evaluation, and all the other goodies). I'm no expert yet, but I've already begun to find it easier to reason "functionally" than imperatively for basic algorithms (and I'm having trouble going back where I have to). The one area where current FP seems to fall flat, however, is GUI programming. The Haskell approach seems to be to just wrap imperative GUI toolkits (such as GTK+ or wxWidgets) and to use "do" blocks to simulate an imperative style. I haven't used F#, but my understanding is that it does something similar using OOP with .NET classes. Obviously, there's a good reason for this--current GUI programming is all about IO and side effects, so purely functional programming isn't possible with most current frameworks. My question is, is it possible to have a functional approach to GUI programming? I'm having trouble imagining what this would look like in practice. Does anyone know of any frameworks, experimental or otherwise, that try this sort of thing (or even any frameworks that are designed from the ground up for a functional language)? Or is the solution to just use a hybrid approach, with OOP for the GUI parts and FP for the logic? (I'm just asking out of curiosity--I'd love to think that FP is "the future," but GUI programming seems like a pretty large hole to fill.)

    Read the article

  • How to get date format in result set?

    - by Prasanna
    I have a sql to get data form mysql their I used dateformat to convert date required format Here is the sql SELECT m.id, m.subject, m.body, m.read, m.hide, m.thread_id, DATE_FORMAT(m.sent_date, '%d-%b-%Y') sent_date, u.username to_name FROM messages m, users u WHERE u.school_id = m.school_id AND u.id = m.to_user_id AND m.school_id = 18 AND m.user_id = 53 AND m.status = 'sent' ORDER BY m.sent_date DESC When I run this sql directly in mysql it works fine, sent_date comes as (19-Apr-2010). When I excute this in ruby, in result set the sent_date is stores as (Tue Apr 20 00:00:00 UTC 2010) messages = Message.find_by_sql(sql) puts messages[0]['sent_date'] puts statement prints "Tue Apr 20 00:00:00 UTC 2010" how to get same date format in mysql result and ruby result set. Thanks

    Read the article

  • Binding list of objects to WPF ListView

    - by Dave Colwell
    Hi all, I have a list of objects which i want to bind to a ListView control in my WPF application. The Objects have a DataTemplate already, so no need to define that. The list of objects is a property in the codebehind file in the format list<object> When i add one object programatically, it appears fine. But when i try to bind the ItemSource of the ListBox to the list of objects, nothing shows up. I am using the following binding: ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=Portfolios}" where the name of the property i am trying to bind to is Portfolios and exists on the parent window

    Read the article

  • code to ping websites works sometimes ...

    - by trustfundbaby
    I'm testing out a piece of code to ping a bunch of websites I own on a regular basis, to make sure they're up. I'm using rails and so far I have this hideous test action that I'm using to try it out (see below). The problem though, is that sometimes it works, and other times it won't ... sometimes it runs through the code just fine, other times, it seems to completely ignore the begin/rescue block ... a. I need help figuring out what the problem is b. And refactoring this to make it look respectable. Your help is much appreciated. require 'net/http' require 'uri' def ping @sites = NewsSource.all @sites.each do |site| if site.uri and !site.uri.empty? uri = URI.parse(site.uri) response = nil path = uri.path.blank? ? '/' : uri.path path = uri.query.blank? ? path : "#{path}?#{uri.query}" begin Net::HTTP.start(uri.host, uri.port) {|http| http.open_timeout = 30 http.read_timeout = 30 response = http.head(path) } if response.code.eql?('200') or response.code.eql?('301') or response.code.eql?('302') site.up = true else site.up = false end site.up_check_msg = response.message site.up_check_code = response.code rescue Errno::EBADF rescue Timeout::Error site.up = false site.up_check_msg = 'timeout' site.up_check_code = '408' end site.up_check_time = 0.seconds.ago site.save end end end

    Read the article

  • How to use offline mode in Safari

    - by Nathaniel
    So, I'm kind of falling in love with Safari 4 (sorry, Firefox). However, I'm the type who likes my browser cache. Doing a little bit of Googling, it seems Safari does have an offline mode like Firefox, Internet Explorer, and Opera (where you can view cached web pages offline), but I haven't found any way to activate it and just navigating to web pages with no net connection seems not to do it either. So, does Safari even really have an offline mode, and if so, how does one use it?

    Read the article

  • Can I charge USB devices from a powered hub that isn't connected to a PC?

    - by Anodyne
    This will probably sound familiar to most of you... In my home, we have a whole bunch of devices that can be charged via USB (two iPhones, a BlackBerry, an iPod Touch, etc ad nauseam). We also have a bunch of USB chargers, each of which has a single USB port on it. I'd like to have something permanently connected to AC power with at least 4 USB ports on it, so we can just plug devices in and don't need to go looking for a free outlet. So here's the question: if I buy a powered USB hub, will that do the job even if I don't connect it to a PC? Ideally if you have a hub that you can personally verify will be suitable, let me know the manufacturer and model :-) Thanks in advance! EDIT: The solution I eventually went for was this: Kensington 4-Port USB Charger for Mobile Devices (Europe) There's also a US version here: Kensington 4-Port USB Charger for Mobile Devices (USA) It arrived yesterday, so I used it to charge the following devices, all at the same time, overnight last night: 32GB iPhone 3GS 16GB iPhone 3G First-generation iPod Touch Kensington Portable Power Pack for Mobile Devices I can't say anything about the charging speed (as I left it overnight) but all devices were fully charged this morning.

    Read the article

  • Computer doesn't boot with Entertainmen Keyboard 8000?

    - by Smetad Anarkist
    I have a Microsoft Wireless Entertainment Keyboard 8000, and when the charger/usb-hub is connected, the computer won't start. All I get is the bios boot screen, and it won't go further. But if I disconnect either the usb-cable or the power-cable to the charger the computer boots normally. Any suggestions as to what's causing this behaviour? I've tried the charger on two different computers with the same result.

    Read the article

  • MacBook Air: USB Hub Compatible with the MBA SuperDrive

    - by _ande_turner_
    A little background to those whom may think this Question to specific: The MacBook Air SuperDrive draws 1A vs 500mA of a normal USB device, and therefore you can't use a standard USB hub powered or unpowered because each port gets 500mA not 1A... Have any MacBook Air users found a USB hub which can accommodate the MBA SuperDrive and another peripheral?

    Read the article

  • How to Implement Web Based Find File Database Text Search

    - by neversaint
    I have series of files like this: foo1.txt.gz foo2.txt.gz bar1.txt.gz ..etc.. and a tabular format files that describe the file foo1 - Explain foo1 foo2 - Explain foo2 bar1 - Explain bar1 ..etc.. What I want to do is to have a website with a simple search bar and allow people to type foo1 or just foo and finally return the gzipped file(s) and the explanation of the file(s). What's the best way to implement this. Sorry I am totally new in this area.

    Read the article

  • Add UIView behind UITableView in UITableViewController code

    - by Drew C
    I would like to use a fixed image as the background in a simple grouped table view in my iPhone program. Unfortunately, no matter what I do, the background is always solid white. I have followed several supposed solutions on this site and others to no avail. Here is the relavant code in the viewDidLoad method of the table view controller class (note, this code uses a solid blue color rather than an image for simplicity's sake): self.tableView.opaque = NO; self.tableView.backgroundColor = [UIColor clearColor]; UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; backgroundView.backgroundColor = [UIColor blueColor]; [self.tableView.window addSubview:backgroundView]; [backgroundView release]; I suspect that I am not positioning the backgroundView view in the right place. I have tried sendToBack:, bringToFront:, and others but I always just get a white background. Is it possible to do this from within the UITableViewController? Must I use Interface Builder?

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >