Search Results

Search found 2264 results on 91 pages for 'odd rationale'.

Page 8/91 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • What is a more "ruby way" to write this code?

    - by steadfastbuck
    This was a homework assignment for my students (I am a teaching assistant) in c and I am trying to learn Ruby, so I thought I would code it up. The goal is to read integers from a redirected file and print some simple information. The first line in the file is the number of elements, and then each integer resides on its own line. This code works (although perhaps inefficiently), but how can I make the code more Ruby-like? #!/usr/bin/ruby -w # first line is number of inputs (Don't need it) num_inputs = STDIN.gets.to_i # read inputs as ints h = Hash.new STDIN.each do |n| n = n.to_i h[n] = 1 unless h[n] and h[n] += 1 end # find smallest mode h.sort.each do |k,v| break puts "Mode is: #{k}", "\n" if v == h.values.max end # mode unique? v = h.values.sort print "Mode is unique: " puts v.pop == v.pop, "\n" # print number of singleton odds, # odd elems repeated odd number times in desc order # even singletons in desc order odd_once = 0 odd = Array.new even = Array.new h.each_pair do |k, v| odd_once += 1 if v == 1 and k.odd? odd << k if v.odd? even << k if v == 1 and k.even? end puts "Number of elements with an odd value that appear only once: #{odd_once}", "\n" puts "Elements repeated an odd number of times:" puts odd.sort.reverse, "\n" puts "Elements with an even value that appear exactly once:" puts even.sort.reverse, "\n" # print fib numbers in the hash class Fixnum def is_fib? l, h = 0, 1 while h <= self return true if h == self l, h = h, l+h end end end puts "Fibonacci numbers:" h.keys.sort.each do |n| puts n if n.is_fib? end

    Read the article

  • How does this code block works?

    - by Justin John
    I can't understand how the following code works. $start = 1; while($start<10){ if ($start&1) { echo "ODD ".$start." <br/> "; } else { echo "EVEN ".$start." <br/> "; } $start++; } The $start&1 will return ODD and EVEN seperately. Output ODD 1 EVEN 2 ODD 3 EVEN 4 ODD 5 EVEN 6 ODD 7 EVEN 8 ODD 9 If we give $start&2 instead of $start&1, it returns with another order. How &1 &2 etc... works here?

    Read the article

  • Strange Maintenance Plan SubPlans behaviour: each SP runs all the tasks of all other SP at odd times

    - by Wentu
    SQL Server 2005: I have a problem with scheduling a Maintenance Plan (MP) with 3 subplans (SP). SP1 is scheduled to run hourly, SP2 daily at 7.00 and SP3 on sundays at 8.00 Reading MP history I see that what happened (I know it seems crazy) is: 11: SP1 runs and executes all the tasks of SP1 SP2 and SP3 12: SP2 runs and does the same 13: SP3 runs and does the same 14: SP1 runs and does the same From the job Activity monitor, SP1 has last run time at 14, SP2 and SP3 are never been executed. All of the SP are scheduled correctly in the Job Activity Monitor (SP2 for tomorrow at 7, SP3 for next sunday at 8) Do you have any idea what is happening? Thankx a lot Wentu

    Read the article

  • How much power supply do I need for my server, and could a shortage be causing my odd crashing?

    - by dolan
    I have 5 servers, all with similar hardware (i7, four 2tb 7200rpm drives, two 4tb 5400rpm drives, 430 watt power supply), and lately the machines have been freezing up. This has gotten worse in the last day or so, and I can't pinpoint any explanation. One recent change was adding the two 4tb hard drives. The crashes happen most often while running a large Hadoop job, so I was originally thinking the load was causing some issues, but last night one server just froze without any heavy load on the box (or so I think), other than HDFS (Hadoop's distributed file system) was probably rebalancing itself since two of the five nodes were offline. If I plugin a monitor and keyboard to one of these frozen machines, I can't get any response or feedback on the screen. Any ideas on possible points of failure and/or different logs I can look at to investigate? Thanks Edit: The systems are running Ubuntu 10.04 Edit 2: More on hardware: intel core i7-930 bloomfield 2.8ghz processor (quad core) 12gb (6 x 2gb) kingston ddr3 1333 ram antec earthwatts green 430 power supply msi x58m lga 1366 motherboard

    Read the article

  • Starting a guest session from the login screen

    - by Odd-rationale
    I was wondering what is the best way to start the guest session from the login screen (GDM). Currently, I created a new user called 'ubuntu-guest' (has to be something other than 'guest'). Then added the following script to the Startup Applications. #!/bin/bash /usr/share/gdm/guest-session/guest-session-launch & /usr/bin/gnome-session-save --logout The problem with this method, is that when you log in as 'ubuntu-guest', you have to start up two gnome sessions: one for 'ubuntu-guest' and one for the actual guest account. Please let me know if you have any other better ideas. Thanks!

    Read the article

  • odd problem with jni interacting with dll's - not sure why a change to gc ergonomics fixes it

    - by jim hale
    We were having a problem with our Tomcat jvm blowing up and giving us an hs_* dump at random times but always in the same spot, that wasn't very informative other than saying we had an EXCEPTION_ACCESS_VIOLATION Commenting out various parts of the java that called particular jni functions just made it blow consistently in another spot. By changing our jvm options from: set PAF_OPTS=-Xms1024m -Xmx32000m -server -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+DisableExplicitGC -XX:+UseCompressedOops -Djava.library.path="%CATALINA_HOME%"\jni -Dcom.sun.management.jmxremote TO set PAF_OPTS=-Xms1024m -Xmx32000m -server -XX:+DisableExplicitGC -XX:+UseCompressedOops -Djava.library.path="%CATALINA_HOME%"\jni -Dcom.sun.management.jmxremote The problem went away. The solution does not give me a warm and fuzzy however and am wondering anyone might understand what's going on under the covers here. Environment: jdk1.6, 64 bit OS and Java, Tomcat, Windows

    Read the article

  • Static lib that links another static lib and qmake? Odd linking error

    - by Dan O
    I have two qt .pro files, both using the lib TEMPLATE and staticlib CONFIG. The first library (lets call it 'core') is a dependency for the second lib (I'll call it 'foo'). In fact, there's a class in foo that extends a class in core, I will call this class Bar. When I instantiate the class (which is defined and implemented in foo, but extends a class (Bar) from core) in another project (not a lib) I get the following linking error: /usr/bin/ld: Undefined symbols: Bar::Bar() Basically, the linker cannot find the class in the core lib that has been derived in the foo lib, but ONLY when I instantiate the class in a third project that is using both libs. Is this behaviour expected? Regards, Dan O Update: I fixed it by directly invoking the Bars constructor in the third project before using derived class... does anyone know why I need to do this?

    Read the article

  • ASP.NET site sometimes freezing up and/or showing odd text at top of the page while loading, on load

    - by MGOwen
    I have various servers (dev, 2 x test, 2 x prod) running the same asp.net site. The test and prod servers are in load-balanced pairs (prod1 with prod2, and test1 with test2). The test server pair is exhibiting some kind of (super) slowdown or freezing during about one in ten page loads. Sometimes a line of text appears at the very top of the page which looks something like: 00 OK Date: Thu, 01 Apr 2010 01:50:09 GMT Server: Microsoft-IIS/6.0 X-Powered_By: ASP.NET X-AspNet-Version:2.0.50727 Cache-Control:private Content-Type:text/html; charset=ut (the beginning and end are "cut off".) Has anyone seen anything like this before? Any idea what it means or what's causing it? Edit: I often see this too when clicking something - it comes up as red text on a yellow page: XML Parsing Error: not well-formed Location: http://203.111.46.211/3DSS/CompanyCompliance.aspx?cid=14 Line Number 1, Column 24:2mMTehON9OUNKySVaJ3ROpN" / -----------------------^ If I go back and click again, it works (I see the page I clicked on, not the above error message). Update: ...And, instead of the page loading, I sometimes just get a white screen with text like this in black (looks a lot like the above text): HTTP/1.1 302 Found Date: Wed, 21 Apr 2010 04:53:39 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Location: /3DSS/EditSections.aspx?id=3&siteId=56&sectionId=46 Set-Cookie: .3DSS=A6CAC223D0F2517D77C7C68EEF069ABA85E9392E93417FFA4209E2621B8DCE38174AD699C9F0221D30D49E108CAB8A828408CF214549A949501DAFAF59F080375A50162361E4AA94E08874BF0945B2EF; path=/; HttpOnly Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 184 object moved here Where "here" is a link that points to a URL just like the one I'm requesting, except with an extra folder in it, meaning something like: http://123.1.2.3/MySite//MySite/Page.aspx?option=1 instead of: http://123.1.2.3/MySite/Page.aspx?option=1 Update: A colleague of mine found some info saying it might be because the test servers are running iis in 64 bit (64bit win 2003) (prod servers are 32 bit win 2003). So we tried telling IIS to use 32 bit: **cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1 %SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i ** (from this MS support page) But iis stopped working altogether (got "server unavailable" on a white page instead of web sites). Reversing the above (see the link) didn't work at first either. The ASP.NET tab disappeared from our IIS web site properties and we had to mess around for an hour uninstalling (aspnet_regiis.exe -u) and reinstalling 32 bit ASP.NET and adding Default.aspx manually back into default documents. We'll probably try again in a few days, if anyone has anything to add in the meantime, please do.

    Read the article

  • ASP.NET site freezing up, showing odd text at top of the page while loading, on one server

    - by MGOwen
    I have various servers (dev, 2 x test, 2 x prod) running the same asp.net site. The test and prod servers are in load-balanced pairs. One of these pairs is exhibiting some kind of (super) slowdown or freezing every other page load or so. Sometimes a line of text appears at the very top of the page which looks something like: 00 OK Date: Thu, 01 Apr 2010 01:50:09 GMT Server: Microsoft-IIS/6.0 X-Powered_By: ASP.NET X-AspNet-Version:2.0.50727 Cache-Control:private Content-Type:text/html; charset=ut (the beginning and end are "cut off".) Has anyone seen anything like this before? Any idea what it means or what's causing it?

    Read the article

  • SqlCe odd results why? -- Same SQL, different results in different apps. Issue with

    - by NitroxDM
    When I run this SQl in my mobile app I get zero rows. select * from inventory WHERE [ITEMNUM] LIKE 'PUMP%' AND [LOCATION] = 'GARAGE' When I run the same SQL in Query Analyzer 3.5 using the same database I get my expected one row. Why the difference? Here is the code I'm using in the mobile app: SqlCeCommand cmd = new SqlCeCommand(Query); cmd.Connection = new SqlCeConnection("Data Source="+filePath+";Persist Security Info=False;"); DataTable tmpTable = new DataTable(); cmd.Connection.Open(); SqlCeDataReader tmpRdr = cmd.ExecuteReader(); if (tmpRdr.Read()) tmpTable.Load(tmpRdr); tmpRdr.Close(); cmd.Connection.Close(); return tmpTable; UPDATE: For the sake of trying I used the code found in one of the answers found here and it works as expected. So my code looks like this: SqlCeConnection conn = new SqlCeConnection("Data Source=" + filePath + ";Persist Security Info=False;"); DataTable tmpTable = new DataTable(); SqlCeDataAdapter AD = new SqlCeDataAdapter(Query, conn); AD.Fill(tmpTable); The issue appears to be with the SqlCeDataReader. Hope this helps someone else out!

    Read the article

  • class on td is causing tr not to respond

    - by Catfish
    I have this script and the rows that have td class "odd" will not toggle the blue color that the rows without the class "odd" do. anybody know why? //Used to make a row turn blue if available $('tr:not(theadtr)').toggle(function() { $(this).addClass("hltclick"); }, function() { $(this).removeClass("hltclick"); }); and this table <table> <thead> <tr class="border"> <td>Start Time</td> <td>End Time</td> </tr> </thead> <tbody> <tr class="border"> <td class="odd"><a href="#">7:00am</a></td> <td class="odd"><a href="#">8:00am</a></td> </tr> <tr class="border"> <td><a href="#">8:00am</a></td> <td><a href="#">9:00am</a></td> </tr> <tr class="border"> <td class="odd"><a href="#">9:00am</a></td> <td class="odd"><a href="#">10:00am</a></td> </tr> <tr class="border"> <td><a href="#">10:00am</a></td> <td><a href="#">11:00am</a></td> </tr> <tr class="border"> <td class="odd"><a href="#">11:00am</a></td> <td class="odd"><a href="#">12:00pm</a></td> </tr> <tr class="border"> <td><a href="#">1:00pm</a></td> <td><a href="#">2:00pm</a></td> </tr> <tr class="border"> <td class="odd"><a href="#">2:00pm</a></td> <td class="odd"><a href="#">3:00pm</a></td> </tr> <tr class="border"> <td><a href="#">3:00pm</a></td> <td><a href="#">4:00pm</a></td> </tr> <tr class="border"> <td class="odd"><a href="#">4:00pm</a></td> <td class="odd"><a href="#">5:00pm</a></td> </tr> </tbody> </table> and this css #calendar { -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px; padding:15px; clear:both; padding:15px; } body { color:#222222; font-family:sans-serif; font-size:12px; } table { border:1px solid white; border-collapse:collapse; margin:0 0 30px; width:100%; } .border { border:1px solid #333134; } thead tr { background:none repeat scroll 0 0 #B7EBFF; color:#333134; font-size:24px; font-weight:bold; } tr { background:none repeat scroll 0 0 #616062; font-size:16px; } thead td { font-family:"Century Gothic",Arial; padding:5px 0 20px 5px; } tr.border thead tr { color:#333134; font-size:24px; font-weight:bold; } tr { font-size:16px; }

    Read the article

  • Odd Series of Packets, How would I reproduce this behavior?

    - by JustSmith
    I recorded a series of http packets that I cant programmatically recreate. The series of packets goes like this: HTTP GET /axis-cgi/admin/param.cgi?action=list&group=Network.eth0.MACAddress,Properties.System.SerialNumber,DVTelTest,SightLogix.ProdShortName HTTP/1.1 HTTP HTTP/1.1 200 OK (text/plain) HTTP GET /axis-cgi/admin/param.cgi?action=list&group=Properties.Image.Resolution HTTP/1.1 HTTP HTTP/1.1 200 OK (text/plain) HTTP GET /axis-cgi/admin/param.cgi?action=update&Network.RTSP.ProtViewer=password HTTP/1.1 HTTP GET /axis-cgi/admin/param.cgi?action=list&group=Event HTTP/1.1 HTTP HTTP/1.1 200 OK (text/plain) HTTP GET /axis-cgi/admin/param.cgi?action=list&group=ImageSource.I0.Sensor HTTP/1.1 HTTP HTTP/1.1 200 OK (text/plain) Notice the two GET followed by one response. I though the two gets were going out at the same time but there is no corresponding number of responses. Also when trying to reproduce this pattern as the server if I abort the first GET request the client waits until it times out and starts the request over with out sending any other requests. What is happening here? How can I reproduce it?

    Read the article

  • How to write custom (odd) authentication plugins for Wordpress, Joomla and MediaWiki?

    - by Bart van Heukelom
    On our network (a group of related websites - not a LAN) we have a common authentication system which works like this: On a network site ("consumer") the user clicks on a login link This redirects the user to a login page on our auth system ("RAS"). Upon successful login the user is directed back to the consumer site. Extra data is passed in the query string. This extra data does not include any information about the user yet. The consumer site's backend contacts RAS, with this extra data, to get the information about the logged in user (id, name, email, preferences, etc.). So as you can see, the consumer site knows nothing about the authentication method. It doesn't know if it's by username/password, fingerprint, smartcard, or winning a game of poker. This is the main problem I'm encountering when trying to find out how I could write custom authentication plugins for these packages, acting as consumer sites: Wordpress Joomla MediaWiki For example Joomla offers a pretty simple auth plugin system, but it depends on a username/password entered on the Joomla site. Any hints on where to start?

    Read the article

  • Can you solve my odd Sharepoint CSS cache / customising problem?

    - by Aidan
    I have a weird situation with my sharepoint css. It is deployed as part of a .wsp solution and up until now everything has been fine. The farm it deploys too has a couple of webfront ends and a single apps server and SQL box. The symptom is that if I deploy the solution, then use a webbrowser to view the page it has no styles, and if I access the .css directly I see the first 100 or so bytes of the .css. However if I go into sharepoint designer and look at the file it is looks fine, and if I check it out and publish it (customising the file but not actually changing anything in it) then the website works fine and the css downloads completely. There is some fairly complex caching on the servers Disk based and object caches. as far as I can tell I have cleared these (and an issreset should clear them anyway... shouldn't it?) I have used this tool to clear the blobcache from the whole farm http://blobcachefarmflush.codeplex.com/

    Read the article

  • Can you explain this odd behavior with dragging items into nested sortables?

    - by RDL
    I have the following setup: A sortable list where one of the <li> has a table with lists in each cell. All of the lists are sortable with each other. Draggable items that can be added to any of the sortables Issue: When adding a draggable item ('drag 1', 'drag 2', 'drag 3') to one of the lists in the horizontal lists (table of lists) it duplicates the draggable when dropped. Sometimes it will create both copies in the same list or one in the item list and one in the column list. Here is a demo: http://jsfiddle.net/MQTgA/ Question: How do I prevent the second item being created when dropping the draggable?

    Read the article

  • Why does the web page I fetch with Perl look odd?

    - by Tichomir Mitkov
    I have a Perl script to open this page http://svejo.net/popular/all/new/ and filter the names of the posts but except headers everything seems encrypted. Nothing can be read. When I open the same page in a browser everything looks fine including the source code. How is it possible to encrypt a page for a script and not for a browser? My Perl script sends the same headers as my browser (Google Chrome).

    Read the article

  • Odd SQL behavior, I'm wondering why this works the way it does.

    - by Matthew Vines
    Consider the following Transact sql. DECLARE @table TABLE(val VARCHAR(255) NULL) INSERT INTO @table (val) VALUES('a') INSERT INTO @table (val) VALUES('b') INSERT INTO @table (val) VALUES('c') INSERT INTO @table (val) VALUES('d') INSERT INTO @table (val) VALUES(NULL) select val from @table where val not in ('a') I would expect this to return b, c, d, NULL but instead it returns b, c, d Why is this the case? Is NULL not evaluated? Is NULL somehow in the set 'a'?

    Read the article

  • How do I change the list using mutable lists in Racket or Scheme?

    - by exOne
    I need your help Can anyone help me? first question This procedure should modify each element which’s index in the list is even. The value of the element should be equal to the new-element. For example: (define number-list (1 56 8 1 43 9 78)) (modify-even-indices number-list 10) The new list: 1 10 8 10 43 10 78 second question This problem is the extended version of Question 1. (modify-even-odd-indices my-list new-element modification-type) This procedure should modify each element according to the modification-type. The modification-type can be even or odd. For example: (define number-list (1 56 8 1 43 9 78)) (modify-even-odd-indices number-list 10 ‘even’) The new list: 1 10 8 10 43 10 78 (modify-even-odd-indices number-list 10 ‘odd’) The new list: 10 56 10 1 10 9 10

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >