Search Results

Search found 4955 results on 199 pages for 'range'.

Page 32/199 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • Python performance: iteration and operations on nested lists

    - by J.J.
    Problem Hey folks. I'm looking for some advice on python performance. Some background on my problem: Given: A mesh of nodes of size (x,y) each with a value (0...255) starting at 0 A list of N input coordinates each at a specified location within the range (0...x, 0...y) Increment the value of the node at the input coordinate and the node's neighbors within range Z up to a maximum of 255. Neighbors beyond the mesh edge are ignored. (No wrapping) BASE CASE: A mesh of size 1024x1024 nodes, with 400 input coordinates and a range Z of 75 nodes. Processing should be O(x*y*Z*N). I expect x, y and Z to remain roughly around the values in the base case, but the number of input coordinates N could increase up to 100,000. My goal is to minimize processing time. Current results I have 2 current implementations: f1, f2 Running speed on my 2.26 GHz Intel Core 2 Duo with Python 2.6.1: f1: 2.9s f2: 1.8s f1 is the initial naive implementation: three nested for loops. f2 is replaces the inner for loop with a list comprehension. Code is included below for your perusal. Question How can I further reduce the processing time? I'd prefer sub-1.0s for the test parameters. Please, keep the recommendations to native Python. I know I can move to a third-party package such as numpy, but I'm trying to avoid any third party packages. Also, I've generated random input coordinates, and simplified the definition of the node value updates to keep our discussion simple. The specifics have to change slightly and are outside the scope of my question. thanks much! f1 is the initial naive implementation: three nested for loops. 2.9s def f1(x,y,n,z): rows = [] for i in range(x): rows.append([0 for i in xrange(y)]) for i in range(n): inputX, inputY = (int(x*random.random()), int(y*random.random())) topleft = (inputX - z, inputY - z) for i in xrange(max(0, topleft[0]), min(topleft[0]+(z*2), x)): for j in xrange(max(0, topleft[1]), min(topleft[1]+(z*2), y)): if rows[i][j] <= 255: rows[i][j] += 1 f2 is replaces the inner for loop with a list comprehension. 1.8s def f2(x,y,n,z): rows = [] for i in range(x): rows.append([0 for i in xrange(y)]) for i in range(n): inputX, inputY = (int(x*random.random()), int(y*random.random())) topleft = (inputX - z, inputY - z) for i in xrange(max(0, topleft[0]), min(topleft[0]+(z*2), x)): l = max(0, topleft[1]) r = min(topleft[1]+(z*2), y) rows[i][l:r] = [j+1 for j in rows[i][l:r] if j < 255]

    Read the article

  • Using Excel VBA to send emails. Problem with attachments becoming embedded by accident.

    - by Alexei
    Hi, I am having an issue with an Excel macro I wrote that is used by several users within my company. It is used to send numerous emails daily with attachments that are also Excel workbooks. The issue is that sometimes, instead of the file simply being attached as it should be, it becomes an embedded object. This embedded object is openable by users on the email within the company (after clicking through the "YOu are about to activate an embedded object that may contain viruses or be otherwise harmful to your computer. It is important to be certain that it is from a trustworthy source. Do you want to continue?"), but those outside of the company do not see it at all. The email appears to have no attachment at all. Curiously, this appears to happen randomly, and only on some computers. So if the list has 15 email lists and attachments, it seems to happen randomly to anywhere between 0 and 15 of the emails. To be clear, my objective is to send emails with regular attachments. Running Excel 2003, Outlook 2003, and Windows XP. See code below. Please help! Sub Email() Dim P As String Dim N As String Dim M As String Dim Subject As String Dim Addresses As String Dim olApp As Outlook.Application Dim olNewMail As Outlook.MailItem Application.DisplayAlerts = False M = ActiveWorkbook.Name For c = 2 To 64000 If Range("B" & c) = "" Then Exit For If UCase(Range("E" & c)) = "Y" Then Workbooks(M).Sheets("Main").Activate Subject = Range("A" & c) Addresses = Range("B" & c) P = Range("C" & c) N = Range("D" & c) If Right(P, 1) <> "\" Then P = P & "\" If Right(N, 4) <> ".xls" Then N = N & ".xls" Set olApp = New Outlook.Application Set olNewMail = olApp.CreateItem(olMailItem) With olNewMail .Display .Recipients.Add Addresses Application.Wait (Now + TimeValue("0:00:01")) SendKeys ("{TAB}") .Subject = Subject .Attachments.Add P + N .Send End With Set olNewMail = Nothing Set olApp = Nothing End If Next c Range("E2:E65536").ClearContents Application.DisplayAlerts = True End Sub

    Read the article

  • ISC DHCP - Force clients to get a new IP address, instead of the being re-issued their previous lease's IP

    - by kce
    We are in the middle of a migration of our DHCP and DNS services from a Debian-based server to a Windows Server 2008 R2 implementation. The Debian server is running isc-dhcpd-V3.1.1. All of workstations are configured to have fixed-addresses between .3 and .40 (the motivation behind that choice is mostly management/political much like here). DHCP leases are given out in the range of .100 to .175. Statically configured servers live in the .200 block and above (which is mostly empty). When we move to the Windows platform, management/political considerations require me to move the IP ranges around again. We would like to keep .1 - .10 reserved for network appliances, switches, and other infrastructure. .200 will remain designated for servers. The addressing space in between should be available to clients and IPs should be dynamically allocated (Edit: instead of automatic as originally mentioned) by the server. My Address Pool on the Windows Server looks like this: 192.168.0.1 192.168.0.254 (Address range for distribution) 192.168.0.1 192.168.0.10 (IP addresses excluded from distribution) 192.168.0.200 192.168.0.254 (IP addresses excluded from distribution) Currently, we have all of our clients still on the .3 - .40 range, and a few machines still active in the .100 - .175 (although there are lots devices that are powered off that still have expired leases with IPs from that range). Since the lease "database" isn't shared between the old and new DHCP server how can I prevent clients from receiving a lease with an IP address that is currently being held by client with a non-expired lease from the old DHCP server? If I just expand the range on the Debian DHCP server to be 192.168.0.10 - 192.168.0.199 is there a way to force clients to not re-use their old IP address when they send their DHCPDISCOVER? Can I make the Windows DHCP server be authoritiative like the ISC implementation? The dhcpd.conf from the Debian server: ddns-update-style none; authoritative; default-lease-time 43200; #12 hours max-lease-time 86400; #24 hours subnet 192.168.0.0 netmask 255.255.255.0 { option routers 192.168.0.1; option subnet-mask 255.255.255.0; option broadcast-address 192.168.0.255; range 192.168.0.100 192.168.0.175; } host workstation-1 { hardware ethernet 00:11:22:33:44:55; fixed-address 192.168.0.3; } ... and so on until 192.168.0.40

    Read the article

  • Insert text into a div from a poput form and rewrite the inserted text with javascript

    - by kuswantin
    So I read some related questions here before I asked, but can't find the answer to my problem. Hope some javascript master here can find this and bring the light to me. I created another button for nicEdit, a video button and wanted to insert some formatted text into the editor DIV (note: nicEdit has inline DIV, no iframe, no textarea). This is my button, recreated from the image button: var nicVideoOptions = { buttons : { 'video' : {name : __('Insert Video'), type : 'nicEditorVideoButton'} //, tags : ['VIDEO:'] }, iconFiles : {'video' : '../movie.png'} }; var nicEditorVideoButton = nicEditorAdvancedButton.extend({ addPane : function() { this.vi = this.ne.selectedInstance.selElm().parentTag('A'); this.addForm({ '' : {type : 'title', txt : 'Insert Video URL'}, 'href' : {type : 'text', txt : 'URL', 'value' : 'http://', style : {width: '150px'}} },this.vi); }, submit : function(e) { var vidVal = this.inputs['href'].value; if(vidVal == "" || vidVal == "http://") { alert("Enter the video url"); return false; } this.removePane(); if(!this.vi) { var tmp = 'javascript:nicVidTemp();'; this.ne.nicCommand("insertVideo",tmp); // still nothing works //this.vi = this.findElm('VIDEO:','href',tmp); //this.vi = this.setContent('[video:' + this.inputs['href'].value + ']'); //nicEditors.findEditor('edit-comment').setContent('<strong>Some HTML</strong> here'); //this.vi = this.setContent('<strong>Some HTML</strong> here'); insertAtCaret(this.ne.selectedInstance, vidVal); } if(this.vi) { // still nothing works //this.vi.setAttributes({ //vidVal : this.inputs['href'].value //}); //this.vi = this.setContent('[video:' + this.inputs['href'].value + ']'); //this.vi = this.setContent('<strong>Some HTML</strong> here'); } } }); nicEditors.registerPlugin(nicPlugin,nicVideoOptions); The button is there, the form poput like the image button, so it's okay. But can't insert the text into the DIV. The final output will be taken from this: ('[video:' + this.inputs['href'].value + ']') and displayed in the editor DIV as is: [video:http//some.com/video-url] As you see, I am blindly touching everything :) And this insertion is taken from: http://www.scottklarr.com/topic/425/how-to-insert-text-into-a-textarea-where-the-cursor-is/ function insertAtCaret(areaId,text) { var txtarea = document.getElementById(areaId); var scrollPos = txtarea.scrollTop; var strPos = 0; var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) ); if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); strPos = range.text.length; } else if (br == "ff") strPos = txtarea.selectionStart; var front = (txtarea.value).substring(0,strPos); var back = (txtarea.value).substring(strPos,txtarea.value.length); txtarea.value=front+text+back; strPos = strPos + text.length; if (br == "ie") { txtarea.focus(); var range = document.selection.createRange(); range.moveStart ('character', -txtarea.value.length); range.moveStart ('character', strPos); range.moveEnd ('character', 0); range.select(); } else if (br == "ff") { txtarea.selectionStart = strPos; txtarea.selectionEnd = strPos; txtarea.focus(); } txtarea.scrollTop = scrollPos; } The flow: I click the button, a form popouts, fill the input text box, hit the query button and the text should appear in the editor DIV. I hope I can make myself clear. Any help would be very much appreaciated Thanks

    Read the article

  • IF Statement in VBA

    - by Edmond
    Private Sub sendemail(esubj) Sheets("Actual").Select myfridate = Cells(1, 3).Value myfridate = DateAdd("d", -2, myfdate) myfridate = Format(myfridate, "mm-dd-yy") Sheets("Actual").Select mysatdate = Cells(1, 3).Value mysatdate = DateAdd("d", -1, myfdate) mysatdate = Format(mysatdate, "mm-dd-yy") If Weekday(Now()) = vbMonday Then Set omail = CreateItem(olMailItem) ROW_BEGIN = 1 ROW_END = 72 Sheet1.Activate Range("I7").Select fileSat = "\\FINANCE\Daily Report\" fileSat = fileSat & Left(Range("I7"), 3) & Right(Year(Date), 2) fileSat = fileSat & "\Key Report - " & mysatdate & ".xls" Sheet1.Activate Range("I7").Select fileSun = "\\FINANCE\Daily Report\" fileSun = fileSun & Left(Range("I7"), 3) & Right(Year(Date), 2) fileSun = fileSun & "\Key Report - " & mysundate & ".xls" Sheet1.Activate Range("I7").Select fileFri = "\\FINANCE\Daily Report\" fileFri = fileFri & Left(Range("I7"), 3) & Right(Year(Date), 2) fileFri = fileFri & "\Key Report - " & myfridate & ".xls" With omail .Subject = "M Daily Report" .BodyFormat = olFormatHTML .HTMLBody = "<a href ='" & fileFri & "'>Key Report - " & myfridate & "</a><br><a href ='" & fileSat & "'>Key Indicator Daily Report - " & mysatdate & "</a><br><a href ='" & fileSun & "'>Key Indicator Daily Report - " & mysundate & "</a>" .To = "Me" .Display End With Set omail1 = CreateItem(olMailItem) With omail1 .Subject = "R Daily Report" .BodyFormat = olFormatHTML .To = "You" .Attachments.Add fileFri .Attachments.Add fileSat .Attachments.Add fileSun .Display End With Set omail2 = CreateItem(olMailItem) With omail2 .Subject = "Mc Daily Report" .BodyFormat = olFormatHTML .To = "them" .Attachments.Add fileFri .Attachments.Add fileSat .Attachments.Add fileSun .Display End With Else ROW_BEGIN = 1 ROW_END = 72 Sheet1.Activate Range("I7").Select fileSun = "\\FINANCE\Key Indicator\" fileSun = fileSun & Left(Range("I7"), 3) & Right(Year(Date), 2) fileSun = fileSun & "\Key Report - " & mysundate & ".xls" Set omail = CreateItem(olMailItem) With omail .Subject = "M Daily Report" .BodyFormat = olFormatHTML .HTMLBody = "<a href ='" & fileSun & "'>Key Report - " & mysundate & "</a>" .To = "Me" .Display End With Set omail1 = CreateItem(olMailItem) With omail1 .Subject = "R Daily Report" .BodyFormat = olFormatHTML .To = "You" .Attachments.Add fileSun .Display End With Set omail2 = CreateItem(olMailItem) With omail2 .Subject = "Mc Daily Report" .BodyFormat = olFormatHTML .To = "them" .Attachments.Add fileSun .Display End With End If 'ActiveWorkbook.Close Set omail = Nothing End Sub I have code in vba, where if the weekday is monday, excel will generate 3 emails with 3 attachements/links. But if it is not Monday, excel will generate 3 emails with only 1 attachment/link. My issue is that In my excel spreadsheet there is a tab called Actual and it is populated with a date. If this date within my excel spreadsheet is changed on a monday, to any other day of the week, my vba code will still treat the program as if it is Monday. I need an IF statement that will allow the 3 emails with the 3 attachements/links to generate given the date typed in on the Actual tab within my spreadsheet. I hope this isnt confusing.

    Read the article

  • Filling cells with sequential numbers in an Excel (2003) macro

    - by Fred Hamilton
    I need to fill an excel column with a sequential series, in this case from -500 to 1000. I've got a macro to do it, but it takes a lot of lines for something that seems like it should be a single function [something like FillRange(A2:A1502, -500, 1000, 1)]. But if that function exists, I can't find it. Is the following as simple and elegant as it gets? 'Draw X axis scale Cells(1, 1).Value = "mV" Cells(2, 1).Value = -500 Cells(3, 1).Value = -499 Cells(4, 1).Value = -498 Dim selection1 As Range, selection2 As Range Set selection1 = Sheet1.Range("A2:A4") Set selection2 = Sheet1.Range("A2:A1502") selection1.AutoFill Destination:=selection2

    Read the article

  • Windows Server 2008 IIS Random disconnect

    - by d123
    I am having a bit of a quirk with my IIS server. I'm running my IIS with 2 sets of IPs configured, one in the 192 range and the other in 172 range. I then have multiple apps which will talk to this server for information. Server has no AV or firewalls configured. I noticed that my apps when talking to the server on the 172 range, at random intervals, the server would just not respond. My apps would then disconnect and just try again, and every thing would be fine. This doesn't happen on the 192 range. So what I did is on a Linux box I did a watch command and to wget a file every half second on the 172 and 192 IPs. I noticed the same issue, every once in awhile wget on the 172 range would not get through, but there is no issues at all on 192. Thus I went around to Wireshark and did a dump. This is the last 3 packets, no other packets were received. 7010 100.871877 200.100.30.7 172.0.0.1 TCP 59619 http [ACK] Seq=140 Ack=85242 Win=64128 Len=0 TSV=1072818795 TSER=1660246133 7011 100.872238 200.100.30.7 172.0.0.1 TCP 59619 http [FIN, ACK] Seq=140 Ack=85242 Win=64128 Len=0 TSV=1072818796 TSER=1660246133 7013 100.873081 200.100.30.7 172.0.0.1 TCP 59619 http [ACK] Seq=141 Ack=85243 Win=64128 Len=0 TSV=1072818796 TSER=1660246133 So this is my issue, there is a random disconnect every once in awhile. The server doesn't receive the next SYN packet. HELP?

    Read the article

  • VBA code to hide or unhide rows based on a cell value

    - by I AM L
    Heres my code, but its not really doing anything, I dont see anything wrong with it: Private Sub PG1(ByVal Target As Range) If .Range("E50").Value = "Passed" Then Rows("51").EntireRow.Hidden = True End If ElseIf Range("E50").Value = "Failed" Then Rows("51").EntireRow.Hidden = True End If End Sub My intention is that when that specific cell in the previous row is set to "Passed" from the dropdown, then the below row would appear, if its a 'Failed" then it'll be hidden instead.

    Read the article

  • visit counts in advanced segments not consistant

    - by user671201
    My organization has recently noticed an issue when applying advanced segments to visit counts during different time ranges. With no advanced segments turned on, here are the visit counts for Oct 1st - Oct 4th during the time range Sept 8th - Oct 8th: Oct 1 - 7 Oct 2 - 7 Oct 3 - 8 Oct 4 - 5 Again, with no advanced segments turned on, here are the visit counts for Oct 1st - Oct 4th but I've changed the time range to Oct 1st - Oct 4th. As expected, the numbers are the exact same as above: Oct 1 - 7 Oct 2 - 7 Oct 3 - 8 Oct 4 - 5 Now, I turn on the "Non paid search traffic" advanced segment. Here are the visit counts for Oct 1st - Oct 4th during the time range Sept 8th - Oct 8th: Oct 1 - 0 Oct 2 - 0 Oct 3 - 0 Oct 4 - 2 Here is where it gets weird. I keep the advanced segment on, and change the time range to Oct 1st - Oct 4th. This is what I get for the exact same dates as above: Oct 1 - 4 Oct 2 - 2 Oct 3 - 6 Oct 4 - 5 We've found the same inconsistency in our other GA profiles that get much more traffic (the above numbers come from one of our specialized topic blogs), but the inconsistency is less pronounced where there are more visits. My question is: why are the visit counts different for different time ranges when advanced segments are turned on, but exactly the same when no advanced segments are applied? Is this a GA bug or am I missing something about how the advanced segments work?

    Read the article

  • Why isn't pyinstaller making me an .exe file?

    - by Matt Miller
    I am attempting to follow this guide to make a simple Hello World script into an .exe file. I have Windows Vista with an AMD 64-bit processor I have installed Python 2.6.5 (Windows AMD64 version) I have set the PATH (if that's the right word) so that the command line recognizes Python I have installed UPX (there only seems to be a 32-bit version for Windows) and pasted a copy of upx.exe into the Python26 folder as instructed. I have installed Pywin (Windows AMD 64 Python 2.6 version) I have run Pyinstaller's Configure.py. It gives some error messages but seems to complete. I don't know if this is what's causing the problem, so the following is what it says when I run it: C:\Python26\Pyinstaller\branches\py26winConfigure.py I: read old config from C:\Python26\Pyinstaller\branches\py26win\config.dat I: computing EXE_dependencies I: Finding TCL/TK... I: Analyzing C:\Python26\DLLs_tkinter.pyd W: Cannot get binary dependencies for file: W: C:\Python26\DLLs_tkinter.pyd W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Python26\DLLs_ctypes.pyd W: Cannot get binary dependencies for file: W: C:\Python26\DLLs_ctypes.pyd W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Python26\DLLs\select.pyd W: Cannot get binary dependencies for file: W: C:\Python26\DLLs\select.pyd W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Python26\DLLs\unicodedata.pyd W: Cannot get binary dependencies for file: W: C:\Python26\DLLs\unicodedata.pyd W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Python26\DLLs\bz2.pyd W: Cannot get binary dependencies for file: W: C:\Python26\DLLs\bz2.pyd W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Python26\python.exe I: Dependent assemblies of C:\Python26\python.exe: I: amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none I: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_ none... I: Found manifest C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a 1e18e3b_9.0.21022.8_none_750b37ff97f4f68b.manifest I: Searching for file msvcr90.dll I: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21 022.8_none_750b37ff97f4f68b\msvcr90.dll I: Searching for file msvcp90.dll I: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21 022.8_none_750b37ff97f4f68b\msvcp90.dll I: Searching for file msvcm90.dll I: Found file C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21 022.8_none_750b37ff97f4f68b\msvcm90.dll I: Adding Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest I: Adding Microsoft.VC90.CRT\msvcr90.dll I: Adding Microsoft.VC90.CRT\msvcp90.dll I: Adding Microsoft.VC90.CRT\msvcm90.dll W: Cannot get binary dependencies for file: W: C:\Python26\python.exe W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Windows\WinSxS\Manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e 3b_9.0.21022.8_none_750b37ff97f4f68b.manifest I: Analyzing C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.210 22.8_none_750b37ff97f4f68b\msvcr90.dll W: Cannot get binary dependencies for file: W: C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_ 750b37ff97f4f68b\msvcr90.dll W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.210 22.8_none_750b37ff97f4f68b\msvcp90.dll W: Cannot get binary dependencies for file: W: C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_ 750b37ff97f4f68b\msvcp90.dll W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: Analyzing C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.210 22.8_none_750b37ff97f4f68b\msvcm90.dll W: Cannot get binary dependencies for file: W: C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_ 750b37ff97f4f68b\msvcm90.dll W: Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 608, in get Imports return _getImports_pe(pth) File "C:\Python26\Pyinstaller\branches\py26win\bindepend.py", line 275, in _ge tImports_pe importva, importsz = datadirs[1] IndexError: list index out of range I: could not find TCL/TK I: testing for Zlib... I: ... Zlib available I: Testing for ability to set icons, version resources... I: ... resource update available I: Testing for Unicode support... I: ... Unicode available I: testing for UPX... I: ...UPX available I: computing PYZ dependencies... I: done generating C:\Python26\Pyinstaller\branches\py26win\config.dat My Python script (named Hello.py) is the same as the example: #!/usr/bin/env python for i in xrange(10000): print "Hello, World!" This is my BAT file, in the same directory: set PIP=C:\Python26\Pyinstaller\branches\py26win\ python %PIP%Makespec.py --onefile --console --upx --tk Hello.py python %PIP%Build.py Hello.spec When I run Hello.bat in the command prompt several files are made, none of which are an .exe file, and the following is displayed: C:\My Filesset PIP=C:\Python26\Pyinstaller\branches\py26win\ C:\My Filespython C:\Python26\Pyinstaller\branches\py26win\Makespec.py --onefil e --console --upx --tk Hello.py wrote C:\My Files\Hello.spec now run Build.py to build the executable C:\My Filespython C:\Python26\Pyinstaller\branches\py26win\Build.py Hello.spec I: Dependent assemblies of C:\Python26\python.exe: I: amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none Traceback (most recent call last): File "C:\Python26\Pyinstaller\branches\py26win\Build.py", line 1359, in main(args[0], configfilename=opts.configfile) File "C:\Python26\Pyinstaller\branches\py26win\Build.py", line 1337, in main build(specfile) File "C:\Python26\Pyinstaller\branches\py26win\Build.py", line 1297, in build execfile(spec) File "Hello.spec", line 3, in pathex=['C:\My Files']) File "C:\Python26\Pyinstaller\branches\py26win\Build.py", line 292, in _init _ raise ValueError, "script '%s' not found" % script ValueError: script 'C:\Python26\Pyinstaller\branches\py26win\support\useTK.py' n ot found I have limited knowledge with the command prompt, so please take baby steps with me if I need to do something there.

    Read the article

  • Analytic functions – they’re not aggregates

    - by Rob Farley
    SQL 2012 brings us a bunch of new analytic functions, together with enhancements to the OVER clause. People who have known me over the years will remember that I’m a big fan of the OVER clause and the types of things that it brings us when applied to aggregate functions, as well as the ranking functions that it enables. The OVER clause was introduced in SQL Server 2005, and remained frustratingly unchanged until SQL Server 2012. This post is going to look at a particular aspect of the analytic functions though (not the enhancements to the OVER clause). When I give presentations about the analytic functions around Australia as part of the tour of SQL Saturdays (starting in Brisbane this Thursday), and in Chicago next month, I’ll make sure it’s sufficiently well described. But for this post – I’m going to skip that and assume you get it. The analytic functions introduced in SQL 2012 seem to come in pairs – FIRST_VALUE and LAST_VALUE, LAG and LEAD, CUME_DIST and PERCENT_RANK, PERCENTILE_CONT and PERCENTILE_DISC. Perhaps frustratingly, they take slightly different forms as well. The ones I want to look at now are FIRST_VALUE and LAST_VALUE, and PERCENTILE_CONT and PERCENTILE_DISC. The reason I’m pulling this ones out is that they always produce the same result within their partitions (if you’re applying them to the whole partition). Consider the following query: SELECT     YEAR(OrderDate),     FIRST_VALUE(TotalDue)         OVER (PARTITION BY YEAR(OrderDate)               ORDER BY OrderDate, SalesOrderID               RANGE BETWEEN UNBOUNDED PRECEDING                         AND UNBOUNDED FOLLOWING),     LAST_VALUE(TotalDue)         OVER (PARTITION BY YEAR(OrderDate)               ORDER BY OrderDate, SalesOrderID               RANGE BETWEEN UNBOUNDED PRECEDING                         AND UNBOUNDED FOLLOWING),     PERCENTILE_CONT(0.95)         WITHIN GROUP (ORDER BY TotalDue)         OVER (PARTITION BY YEAR(OrderDate)),     PERCENTILE_DISC(0.95)         WITHIN GROUP (ORDER BY TotalDue)         OVER (PARTITION BY YEAR(OrderDate)) FROM Sales.SalesOrderHeader ; This is designed to get the TotalDue for the first order of the year, the last order of the year, and also the 95% percentile, using both the continuous and discrete methods (‘discrete’ means it picks the closest one from the values available – ‘continuous’ means it will happily use something between, similar to what you would do for a traditional median of four values). I’m sure you can imagine the results – a different value for each field, but within each year, all the rows the same. Notice that I’m not grouping by the year. Nor am I filtering. This query gives us a result for every row in the SalesOrderHeader table – 31465 in this case (using the original AdventureWorks that dates back to the SQL 2005 days). The RANGE BETWEEN bit in FIRST_VALUE and LAST_VALUE is needed to make sure that we’re considering all the rows available. If we don’t specify that, it assumes we only mean “RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW”, which means that LAST_VALUE ends up being the row we’re looking at. At this point you might think about other environments such as Access or Reporting Services, and remember aggregate functions like FIRST. We really should be able to do something like: SELECT     YEAR(OrderDate),     FIRST_VALUE(TotalDue)         OVER (PARTITION BY YEAR(OrderDate)               ORDER BY OrderDate, SalesOrderID               RANGE BETWEEN UNBOUNDED PRECEDING                         AND UNBOUNDED FOLLOWING) FROM Sales.SalesOrderHeader GROUP BY YEAR(OrderDate) ; But you can’t. You get that age-old error: Msg 8120, Level 16, State 1, Line 5 Column 'Sales.SalesOrderHeader.OrderDate' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Msg 8120, Level 16, State 1, Line 5 Column 'Sales.SalesOrderHeader.SalesOrderID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. Hmm. You see, FIRST_VALUE isn’t an aggregate function. None of these analytic functions are. There are too many things involved for SQL to realise that the values produced might be identical within the group. Furthermore, you can’t even surround it in a MAX. Then you get a different error, telling you that you can’t use windowed functions in the context of an aggregate. And so we end up grouping by doing a DISTINCT. SELECT DISTINCT     YEAR(OrderDate),         FIRST_VALUE(TotalDue)              OVER (PARTITION BY YEAR(OrderDate)                   ORDER BY OrderDate, SalesOrderID                   RANGE BETWEEN UNBOUNDED PRECEDING                             AND UNBOUNDED FOLLOWING),         LAST_VALUE(TotalDue)             OVER (PARTITION BY YEAR(OrderDate)                   ORDER BY OrderDate, SalesOrderID                   RANGE BETWEEN UNBOUNDED PRECEDING                             AND UNBOUNDED FOLLOWING),     PERCENTILE_CONT(0.95)          WITHIN GROUP (ORDER BY TotalDue)         OVER (PARTITION BY YEAR(OrderDate)),     PERCENTILE_DISC(0.95)         WITHIN GROUP (ORDER BY TotalDue)         OVER (PARTITION BY YEAR(OrderDate)) FROM Sales.SalesOrderHeader ; I’m sorry. It’s just the way it goes. Hopefully it’ll change the future, but for now, it’s what you’ll have to do. If we look in the execution plan, we see that it’s incredibly ugly, and actually works out the results of these analytic functions for all 31465 rows, finally performing the distinct operation to convert it into the four rows we get in the results. You might be able to achieve a better plan using things like TOP, or the kind of calculation that I used in http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx (which is how PERCENTILE_CONT works), but it’s definitely convenient to use these functions, and in time, I’m sure we’ll see good improvements in the way that they are implemented. Oh, and this post should be good for fellow SQL Server MVP Nigel Sammy’s T-SQL Tuesday this month.

    Read the article

  • Index was out of range. Must be non-negative and less than the size of the collection. Parameter: In

    - by user356973
    Dear Telerik Team, When I am trying to display data using radgrid I am getting error like "Index was out of range. Must be non-negative and less than the size of the collection. Parameter: Index". Here is my code <telerik:RadGrid ID="gvCktMap" BorderColor="White" runat="server" AutoGenerateColumns="true" AllowSorting="true" BackColor="White" AllowPaging="true" PageSize="25" GridLines="None" OnPageIndexChanging="gvCktMap_PageIndexChanging" OnRowCancelingEdit="gvCktMap_RowCancelingEdit" OnRowCommand="gvCktMap_RowCommand" OnRowUpdating="gvCktMap_RowUpdating" OnRowDataBound="gvCktMap_RowDataBound" OnSorting="gvCktMap_Sorting" OnRowEditing="gvCktMap_RowEditing" ShowGroupPanel="True" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" AllowMultiRowSelection="true" AllowFilteringByColumn="True" AllowCustomPaging="false" OnItemCreated="gvCktMap_ItemCreated" EnableViewState="false" OnNeedDataSource="gvCktMap_NeedDataSource" OnItemUpdated="gvCktMap_ItemUpdated" > <MasterTableView DataKeyNames="sId" UseAllDataFields="true"> <Columns> <telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" Visible="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" DataField="orderId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="REJ" HeaderText="REJ" DataField="REJ"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="Desc" HeaderText="Desc" DataField="Desc"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="CustomerName" HeaderText="CustomerName" DataField="CustomerName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="MarketName" HeaderText="MarketName" DataField="MarketName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="HeadendName" HeaderText="HeadendName" DataField="HeadendName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="SiteName" HeaderText="SiteName" DataField="SiteName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="TaskStatus" HeaderText="TaskStatus" DataField="TaskStatus"> </telerik:GridBoundColumn> </Columns> </telerik:RadGrid> Here is my code behind private void bingGrid() { try { gvCktMap.Columns.Clear(); DataSet dsResult = new DataSet(); DataSet dsEditItems = new DataSet(); dsEditItems.ReadXml(Server.MapPath("XMLS/" + Session["TaskID"].ToString() + ".xml")); clsSearch_BL clsObj = new clsSearch_BL(); clsObj.TaskID = (string)Session["TaskID"]; clsObj.CustName = (string)Session["CustName"]; clsObj.MarketName = (string)Session["MarketName"]; clsObj.HeadendName = (string)Session["HeadendName"]; clsObj.SiteName = (string)Session["SiteName"]; clsObj.TaskStatus = (string)Session["TaskStatus"]; clsObj.OrdType = (string)Session["OrdType"]; clsObj.OrdStatus = (string)Session["OrdStatus"]; clsObj.ProName = (string)Session["ProName"]; clsObj.LOC = (string)Session["LOC"]; dsResult = clsObj.getSearchResults_BL(clsObj); Session["SearchRes"] = dsResult; DataTable dtFilter = new DataTable(); DataColumn dtCol = new DataColumn("FilterBy"); dtFilter.Columns.Add(dtCol); dtCol = new DataColumn("DataType"); dtFilter.Columns.Add(dtCol); gvCktMap.DataSource = dsResult; gvCktMap.DataBind(); } catch (Exception ex) { } } If i remove <MasterTableView></MasterTableView> Its working fine without any error. But for some reasons i need to use <MasterTableView></MasterTableView> Can anyone help me out to fix this error. Thanks In Advance

    Read the article

  • Muob Package Manager crashes

    - by Woltan
    Clicking on Check for Updates in the kubuntu Muon Package Manager gives the following error message: Unable to download the following packages: Failed to download http://de.archive.ubuntu.com oneiric-updates/universe Sources 416 Requested Range Not Satisfiable [IP: 141.30.13.10 80] Failed to download http://de.archive.ubuntu.com oneiric-updates/multiverse Sources 416 Requested Range Not Satisfiable [IP: 141.30.13.10 80] Failed to download http://de.archive.ubuntu.com oneiric-updates/main i386 Packages 416 Requested Range Not Satisfiable [IP: 141.30.13.10 80] After clicking OK or after just looking at the software sources the package manager crashed with the following error message: The package system could not be initialized, your configuration may be broken. What can I do to fix the problem?

    Read the article

  • Runtime analysis

    - by Joe Smith
    can someone please help me with the analysis of the following function (for inputs of size n). The part that confuses me the most is the inner for loop. def prefix_sums(L): # Total cost = ? pSum = [] #cost = 1 for a in range(len(L)+1): # range + body of function = (n+1) + (n+1)*(body) ? s = 0 #cost = 1 for b in range(a): # cost = ? s = s + L[b] #cost = operation + accessing list = 2 pSum.append(s) #cost = 1 return pSum #cost = 1 What I need to do is figure out the cost of each statement.

    Read the article

  • Exploring TCP throughput with DTrace (2)

    - by user12820842
    Last time, I described how we can use the overlap in distributions of unacknowledged byte counts and send window to determine whether the peer's receive window may be too small, limiting throughput. Let's combine that comparison with a comparison of congestion window and slow start threshold, all on a per-port/per-client basis. This will help us Identify whether the congestion window or the receive window are limiting factors on throughput by comparing the distributions of congestion window and send window values to the distribution of outstanding (unacked) bytes. This will allow us to get a visual sense for how often we are thwarted in our attempts to fill the pipe due to congestion control versus the peer not being able to receive any more data. Identify whether slow start or congestion avoidance predominate by comparing the overlap in the congestion window and slow start distributions. If the slow start threshold distribution overlaps with the congestion window, we know that we have switched between slow start and congestion avoidance, possibly multiple times. Identify whether the peer's receive window is too small by comparing the distribution of outstanding unacked bytes with the send window distribution (i.e. the peer's receive window). I discussed this here. # dtrace -s tcp_window.d dtrace: script 'tcp_window.d' matched 10 probes ^C cwnd 80 10.175.96.92 value ------------- Distribution ------------- count 1024 | 0 2048 | 4 4096 | 6 8192 | 18 16384 | 36 32768 |@ 79 65536 |@ 155 131072 |@ 199 262144 |@@@ 400 524288 |@@@@@@ 798 1048576 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3848 2097152 | 0 ssthresh 80 10.175.96.92 value ------------- Distribution ------------- count 268435456 | 0 536870912 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5543 1073741824 | 0 unacked 80 10.175.96.92 value ------------- Distribution ------------- count -1 | 0 0 | 1 1 | 0 2 | 0 4 | 0 8 | 0 16 | 0 32 | 0 64 | 0 128 | 0 256 | 3 512 | 0 1024 | 0 2048 | 4 4096 | 9 8192 | 21 16384 | 36 32768 |@ 78 65536 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5391 131072 | 0 swnd 80 10.175.96.92 value ------------- Distribution ------------- count 32768 | 0 65536 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 5543 131072 | 0 Here we are observing a large file transfer via http on the webserver. Comparing these distributions, we can observe: That slow start congestion control is in operation. The distribution of congestion window values lies below the range of slow start threshold values (which are in the 536870912+ range), so the connection is in slow start mode. Both the unacked byte count and the send window values peak in the 65536-131071 range, but the send window value distribution is narrower. This tells us that the peer TCP's receive window is not closing. The congestion window distribution peaks in the 1048576 - 2097152 range while the receive window distribution is confined to the 65536-131071 range. Since the cwnd distribution ranges as low as 2048-4095, we can see that for some of the time we have been observing the connection, congestion control has been a limiting factor on transfer, but for the majority of the time the receive window of the peer would more likely have been the limiting factor. However, we know the window has never closed as the distribution of swnd values stays within the 65536-131071 range. So all in all we have a connection that has been mildly constrained by congestion control, but for the bulk of the time we have been observing it neither congestion or peer receive window have limited throughput. Here's the script: #!/usr/sbin/dtrace -s tcp:::send / (args[4]-tcp_flags & (TH_SYN|TH_RST|TH_FIN)) == 0 / { @cwnd["cwnd", args[4]-tcp_sport, args[2]-ip_daddr] = quantize(args[3]-tcps_cwnd); @ssthresh["ssthresh", args[4]-tcp_sport, args[2]-ip_daddr] = quantize(args[3]-tcps_cwnd_ssthresh); @unacked["unacked", args[4]-tcp_sport, args[2]-ip_daddr] = quantize(args[3]-tcps_snxt - args[3]-tcps_suna); @swnd["swnd", args[4]-tcp_sport, args[2]-ip_daddr] = quantize((args[4]-tcp_window)*(1 tcps_snd_ws)); } One surprise here is that slow start is still in operation - one would assume that for a large file transfer, acknowledgements would push the congestion window up past the slow start threshold over time. The slow start threshold is in fact still close to it's initial (very high) value, so that would suggest we have not experienced any congestion (the slow start threshold is adjusted when congestion occurs). Also, the above measurements were taken early in the connection lifetime, so the congestion window did not get a changes to get bumped up to the level of the slow start threshold. A good strategy when examining these sorts of measurements for a given service (such as a webserver) would be start by examining the distributions above aggregated by port number only to get an overall feel for service performance, i.e. is congestion control or peer receive window size an issue, or are we unconstrained to fill the pipe? From there, the overlap of distributions will tell us whether to drill down into specific clients. For example if the send window distribution has multiple peaks, we may want to examine if particular clients show issues with their receive window.

    Read the article

  • Handling large integers in python [migrated]

    - by Sushma Palimar
    I had written a program in python to find b such that a prime number p divides b^2-8. The range for b is [1, (p+1)/2]. For small integers it works, say only up to 7 digits. But not for large integers, say for p = 140737471578113. I get the error message for i in range (2,p1,1): MemoryError I wrote the program as #!/usr/bin/python3 p=long(raw_input('enter the prime number:')) p1=long((p+1)/2) for i in range (2,p1,1): s = long((i*i)-8) if (s%p==0): print i

    Read the article

  • How to get several frequency ranges at the same time in fmod?

    - by Rootosaurus
    After reading documentation and tutorials about fmod I still have a question about frequency ranges. I've found how to get a frequency range using low and high pass DSP at the same time on the main channel, but I can't find how to get several ranges at the same time. For example I want, for a specific phase of my game, to hear range 400 to 600Hz and 1000 to 2000hz of the same sound. I tried to create a channel by range, but it doesn't seem to work (or maybe I do something wrong). How can I do that ? Thank you

    Read the article

  • SQL SERVER – How to Roll Back SQL Server Database Changes

    - by Pinal Dave
    In a perfect scenario, no unexpected and unplanned changes occur. There are no unpleasant surprises, no inadvertent changes. However, even with all precautions and testing, there is sometimes a need to revert a structure or data change. One of the methods that can be used in this situation is to use an older database backup that has the records or database object structure you want to revert to. For this method, you have to have the adequate full database backup and a tool that will help you with comparison and synchronization is preferred. In this article, we will focus on another method: rolling back the changes. This can be done by using: An option in SQL Server Management Studio T-SQL, or ApexSQL Log The first two solutions have been described in this article The disadvantages of these methods are that you have to know when exactly the change you want to revert happened and that all transactions on the database executed in a specific time range are rolled back – the ones you want to undo and the ones you don’t. How to easily roll back SQL Server database changes using ApexSQL Log? The biggest challenge is to roll back just specific changes, not all changes that happened in a specific time range. While SQL Server Management Studio option and T-SQL read and roll forward all transactions in the transaction log files, I will show you a solution that finds and scripts only the specific changes that match your criteria. Therefore, you don’t need to worry about all other database changes that you don’t want to roll back. ApexSQL Log is a SQL Server disaster recovery tool that reads transaction logs and provides a wide range of filters that enable you to easily rollback only specific data changes. First, connect to the online database where you want to roll back the changes. Once you select the database, ApexSQL Log will show its recovery model. Note that changes can be rolled back even for a database in the Simple recovery model, when no database and transaction log backups are available. However, ApexSQL Log achieves best results when the database is in the Full recovery model and you have a chain of subsequent transaction log backups, back to the moment when the change occurred. In this example, we will use only the online transaction log. In the next step, use filters to read only the transactions that happened in a specific time range. To remove noise, it’s recommended to use as many filters as possible. Besides filtering by the time of the transaction, ApexSQL Log can filter by the operation type: Table name: As well as transaction state (committed, aborted, running, and unknown), name of the user who committed the change, specific field values, server process IDs, and transaction description. You can select only the tables affected by the changes you want to roll back. However, if you’re not certain which tables were affected, you can leave them all selected and once the results are shown in the main grid, analyze them to find the ones you to roll back. When you set the filters, you can select how to present the results. ApexSQL Log can automatically create undo or redo scripts, export the transactions into an XML, HTML, CSV, SQL, or SQL Bulk file, and create a batch file that you can use for unattended transaction log reading. In this example, I will open the results in the grid, as I want to analyze them before rolling back the transactions. The results contain information about the transaction, as well as who and when made it. For UPDATEs, ApexSQL Log shows both old and new values, so you can easily see what has happened. To create an UNDO script that rolls back the changes, select the transactions you want to roll back and click Create undo script in the menu. For the DELETE statement selected in the screenshot above, the undo script is: INSERT INTO [Sales].[PersonCreditCard] ([BusinessEntityID], [CreditCardID], [ModifiedDate]) VALUES (297, 8010, '20050901 00:00:00.000') When it comes to rolling back database changes, ApexSQL Log has a big advantage, as it rolls back only specific transactions, while leaving all other transactions that occurred at the same time range intact. That makes ApexSQL Log a good solution for rolling back inadvertent data and schema changes on your SQL Server databases. Reference: Pinal Dave (http://blog.sqlauthority.com)Filed under: PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, T SQL Tagged: ApexSQL

    Read the article

  • Exploring TCP throughput with DTrace

    - by user12820842
    One key measure to use when assessing TCP throughput is assessing the amount of unacknowledged data in the pipe. This is sometimes termed the Bandwidth Delay Product (BDP) (note that BDP is often used more generally as the product of the link capacity and the end-to-end delay). In DTrace terms, the amount of unacknowledged data in bytes for the connection is the different between the next sequence number to send and the lowest unacknoweldged sequence number (tcps_snxt - tcps_suna). According to the theory, when the number of unacknowledged bytes for the connection is less than the receive window of the peer, the path bandwidth is the limiting factor for throughput. In other words, if we can fill the pipe without the peer TCP complaining (by virtue of its window size reaching 0), we are purely bandwidth-limited. If the peer's receive window is too small however, the sending TCP has to wait for acknowledgements before it can send more data. In this case the round-trip time (RTT) limits throughput. In such cases the effective throughput limit is the window size divided by the RTT, e.g. if the window size is 64K and the RTT is 0.5sec, the throughput is 128K/s. So a neat way to visually determine if the receive window of clients may be too small should be to compare the distribution of BDP values for the server versus the client's advertised receive window. If the BDP distribution overlaps the send window distribution such that it is to the right (or lower down in DTrace since quantizations are displayed vertically), it indicates that the amount of unacknowledged data regularly exceeds the client's receive window, so that it is possible that the sender may have more data to send but is blocked by a zero-window on the client side. In the following example, we compare the distribution of BDP values to the receive window advertised by the receiver (10.175.96.92) for a large file download via http. # dtrace -s tcp_tput.d ^C BDP(bytes) 10.175.96.92 80 value ------------- Distribution ------------- count -1 | 0 0 | 6 1 | 0 2 | 0 4 | 0 8 | 0 16 | 0 32 | 0 64 | 0 128 | 0 256 | 3 512 | 0 1024 | 0 2048 | 9 4096 | 14 8192 | 27 16384 | 67 32768 |@@ 1464 65536 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 32396 131072 | 0 SWND(bytes) 10.175.96.92 80 value ------------- Distribution ------------- count 16384 | 0 32768 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 17067 65536 | 0 Here we have a puzzle. We can see that the receiver's advertised window is in the 32768-65535 range, while the amount of unacknowledged data in the pipe is largely in the 65536-131071 range. What's going on here? Surely in a case like this we should see zero-window events, since the amount of data in the pipe regularly exceeds the window size of the receiver. We can see that we don't see any zero-window events since the SWND distribution displays no 0 values - it stays within the 32768-65535 range. The explanation is straightforward enough. TCP Window scaling is in operation for this connection - the Window Scale TCP option is used on connection setup to allow a connection to advertise (and have advertised to it) a window greater than 65536 bytes. In this case the scaling shift is 1, so this explains why the SWND values are clustered in the 32768-65535 range rather than the 65536-131071 range - the SWND value needs to be multiplied by two since the reciever is also scaling its window by a shift factor of 1. Here's the simple script that compares BDP and SWND distributions, fixed to take account of window scaling. #!/usr/sbin/dtrace -s #pragma D option quiet tcp:::send / (args[4]-tcp_flags & (TH_SYN|TH_RST|TH_FIN)) == 0 / { @bdp["BDP(bytes)", args[2]-ip_daddr, args[4]-tcp_sport] = quantize(args[3]-tcps_snxt - args[3]-tcps_suna); } tcp:::receive / (args[4]-tcp_flags & (TH_SYN|TH_RST|TH_FIN)) == 0 / { @swnd["SWND(bytes)", args[2]-ip_saddr, args[4]-tcp_dport] = quantize((args[4]-tcp_window)*(1 tcps_snd_ws)); } And here's the fixed output. # dtrace -s tcp_tput_scaled.d ^C BDP(bytes) 10.175.96.92 80 value ------------- Distribution ------------- count -1 | 0 0 | 39 1 | 0 2 | 0 4 | 0 8 | 0 16 | 0 32 | 0 64 | 0 128 | 0 256 | 3 512 | 0 1024 | 0 2048 | 4 4096 | 9 8192 | 22 16384 | 37 32768 |@ 99 65536 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 3858 131072 | 0 SWND(bytes) 10.175.96.92 80 value ------------- Distribution ------------- count 512 | 0 1024 | 1 2048 | 0 4096 | 2 8192 | 4 16384 | 7 32768 | 14 65536 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1956 131072 | 0

    Read the article

  • Optimized Image Loading in a UIScrollView

    - by Michael Gaylord
    I have a UIScrollView that has a set of images loaded side-by-side inside it. You can see an example of my app here: http://www.42restaurants.com. My problem comes in with memory usage. I want to lazy load the images as they are about to appear on the screen and unload images that aren't on screen. As you can see in the code I work out at a minimum which image I need to load and then assign the loading portion to an NSOperation and place it on an NSOperationQueue. Everything works great apart from a jerky scrolling experience. I don't know if anyone has any ideas as to how I can make this even more optimized, so that the loading time of each image is minimized or so that the scrolling is less jerky. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self manageThumbs]; } - (void) manageThumbs{ int centerIndex = [self centerThumbIndex]; if(lastCenterIndex == centerIndex){ return; } if(centerIndex >= totalThumbs){ return; } NSRange unloadRange; NSRange loadRange; int totalChange = lastCenterIndex - centerIndex; if(totalChange > 0){ //scrolling backwards loadRange.length = fabsf(totalChange); loadRange.location = centerIndex - 5; unloadRange.length = fabsf(totalChange); unloadRange.location = centerIndex + 6; }else if(totalChange < 0){ //scrolling forwards unloadRange.length = fabsf(totalChange); unloadRange.location = centerIndex - 6; loadRange.length = fabsf(totalChange); loadRange.location = centerIndex + 5; } [self unloadImages:unloadRange]; [self loadImages:loadRange]; lastCenterIndex = centerIndex; return; } - (void) unloadImages:(NSRange)range{ UIScrollView *scrollView = (UIScrollView *)[[self.view subviews] objectAtIndex:0]; for(int i = 0; i < range.length && range.location + i < [scrollView.subviews count]; i++){ UIView *subview = [scrollView.subviews objectAtIndex:(range.location + i)]; if(subview != nil && [subview isKindOfClass:[ThumbnailView class]]){ ThumbnailView *thumbView = (ThumbnailView *)subview; if(thumbView.loaded){ UnloadImageOperation *unloadOperation = [[UnloadImageOperation alloc] initWithOperableImage:thumbView]; [queue addOperation:unloadOperation]; [unloadOperation release]; } } } } - (void) loadImages:(NSRange)range{ UIScrollView *scrollView = (UIScrollView *)[[self.view subviews] objectAtIndex:0]; for(int i = 0; i < range.length && range.location + i < [scrollView.subviews count]; i++){ UIView *subview = [scrollView.subviews objectAtIndex:(range.location + i)]; if(subview != nil && [subview isKindOfClass:[ThumbnailView class]]){ ThumbnailView *thumbView = (ThumbnailView *)subview; if(!thumbView.loaded){ LoadImageOperation *loadOperation = [[LoadImageOperation alloc] initWithOperableImage:thumbView]; [queue addOperation:loadOperation]; [loadOperation release]; } } } } EDIT: Thanks for the really great responses. Here is my NSOperation code and ThumbnailView code. I tried a couple of things over the weekend but I only managed to improve performance by suspending the operation queue during scrolling and resuming it when scrolling is finished. Here are my code snippets: //In the init method queue = [[NSOperationQueue alloc] init]; [queue setMaxConcurrentOperationCount:4]; //In the thumbnail view the loadImage and unloadImage methods - (void) loadImage{ if(!loaded){ NSString *filename = [NSString stringWithFormat:@"%03d-cover-front", recipe.identifier, recipe.identifier]; NSString *directory = [NSString stringWithFormat:@"RestaurantContent/%03d", recipe.identifier]; NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:@"png" inDirectory:directory]; UIImage *image = [UIImage imageWithContentsOfFile:path]; imageView = [[ImageView alloc] initWithImage:image andFrame:CGRectMake(0.0f, 0.0f, 176.0f, 262.0f)]; [self addSubview:imageView]; [self sendSubviewToBack:imageView]; [imageView release]; loaded = YES; } } - (void) unloadImage{ if(loaded){ [imageView removeFromSuperview]; imageView = nil; loaded = NO; } } Then my load and unload operations: - (id) initWithOperableImage:(id<OperableImage>) anOperableImage{ self = [super init]; if (self != nil) { self.image = anOperableImage; } return self; } //This is the main method in the load image operation - (void)main { [image loadImage]; } //This is the main method in the unload image operation - (void)main { [image unloadImage]; }

    Read the article

  • MultiWidget in MultiWidget how to compress the first one?

    - by sacabuche
    I have two MultiWidget one inside the other, but the problem is that the MultiWidget contained don't return compress, how do i do to get the right value from the first widget? In this case from SplitTimeWidget class SplitTimeWidget(forms.MultiWidget): """ Widget written to split widget into hours and minutes. """ def __init__(self, attrs=None): widgets = ( forms.Select(attrs=attrs, choices=([(hour,hour) for hour in range(0,24)])), forms.Select(attrs=attrs, choices=([(minute, str(minute).zfill(2)) for minute in range(0,60)])), ) super(SplitTimeWidget, self).__init__(widgets, attrs) def decompress(self, value): if value: return [value.hour, value.minute] return [None, None] class DateTimeSelectWidget (forms.MultiWidget): """ A widget that splits date into Date and Hours, minutes, seconds with selects """ date_format = DateInput.format def __init__(self, attrs=None, date_format=None): if date_format: self.date_format = date_format #if time_format: # self.time_format = time_format hours = [(hour,str(hour)+' h') for hour in range(0,24)] minutes = [(minute,minute) for minute in range(0,60)] seconds = minutes #not used always in 0s widgets = ( DateInput(attrs=attrs, format=self.date_format), SplitTimeWidget(attrs=attrs), ) super(DateTimeSelectWidget,self).__init__(widgets, attrs) def decompress(self, value): if value: return [value.date(), value.time()] else: [None, None, None]

    Read the article

  • Creating a function in ruby

    - by Micke
    Hello, i have some problem with creating a function to my Rails app. I want it to work like this: str = "string here" if str.within_range?(3..30) puts "It's withing the range!" end To do that i added this into my application helper: def within_range?(range) if self.is_a?(String) (range).include?(self.size) elsif self.is_a?(Integer) (range).include?(self) end end But i get this error: undefined method `within_range?' for &quot;&quot;:String Do you know what the problem is? and could you please help me. If there is a easier way please say so then. Thanks in advance, Micke.

    Read the article

  • How can I show figures separately in matplotlib?

    - by Federico Ramponi
    Say that I have two figures in matplotlib, with one plot per figure: import matplotlib.pyplot as plt f1 = plt.figure() plt.plot(range(0,10)) f2 = plt.figure() plt.plot(range(10,20)) Then I show both in one shot plt.show() Is there a way to show them separately, i.e. to show just f1? Or better: how can I manage the figures separately like in the following 'wishful' code (that doesn't work): f1 = plt.figure() f1.plot(range(0,10)) f1.show()

    Read the article

  • Encoding issue - 2nd band of ISO-8859-1 values do not get encoded?

    - by bstack
    Hello, I want to send the pound sign character i.e. '£' encoded as ISO-8859-1 across the wire. I perform this by doing the following: var _encoding = Encoding.GetEncoding("iso-8859-1"); var _requestContent = _encoding.GetBytes(requestContent); var _request = (HttpWebRequest)WebRequest.Create(target); _request.Headers[HttpRequestHeader.ContentEncoding] = _encoding.WebName; _request.Method = "POST"; _request.ContentType = "application/x-www-form-urlencoded; charset=iso-8859-1"; _request.ContentLength = _requestContent.Length; _requestStream = _request.GetRequestStream(); _requestStream.Write(_requestContent, 0, _requestContent.Length); _requestStream.Flush(); _requestStream.Close(); When I put a breakpoint at the target, I expect to receive the following: '%a3', however I receive '%u00a3' instead. ISO-8859-1 is divided into 2 groups of characters: (ref: http://en.wikipedia.org/wiki/ISO_8859-1) The lower range 20 to 7E - is where all characters seem to be encoded correctly The higher range A0 to FF - is where all characters seem to encode to their Unicode equivalent value As '£' is in higher range A0 to FF, it gets encoded to %u00a3. In fact when I use the first few characters of the higher range A0 to FF i.e. '¡¢£¤¥¦§¨©ª«¬®', I get '%u00a1%u00a2%u00a3%u00a4%u00a5%u00a6%u00a7%u00a8%u00a9%u00aa%u00ab%u00ac%u00ae'. This behaviour is consistent. The question I have is why do characters in the higher range A0 to FF get encoded to their unicode value - and not to their equivalent ISO-8859-1 value? Help would be greatly appreciated... Billy

    Read the article

  • Problem with closing excel by c#

    - by phenevo
    Hi, I've got unit test with this code: Excel.Application objExcel = new Excel.Application(); Excel.Workbook objWorkbook = (Excel.Workbook)(objExcel.Workbooks._Open(@"D:\Selenium\wszystkieSeba2.xls", true, false, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)); Excel.Worksheet ws = (Excel.Worksheet)objWorkbook.Sheets[1]; Excel.Range r = ws.get_Range("A1", "I2575"); DateTime dt = DateTime.Now; Excel.Range cellData = null; Excel.Range cellKwota = null; string cellValueData = null; string cellValueKwota = null; double dataTransakcji = 0; string dzien = null; string miesiac = null; int nrOperacji = 1; int wierszPoczatkowy = 11; int pozostalo = 526; cellData = r.Cells[wierszPoczatkowy, 1] as Excel.Range; cellKwota = r.Cells[wierszPoczatkowy, 6] as Excel.Range; if ((cellData != null) && (cellKwota != null)) { object valData = cellData.Value2; object valKwota = cellKwota.Value2; if ((valData != null) && (valKwota != null)) { cellValueData = valData.ToString(); dataTransakcji = Convert.ToDouble(cellValueData); Console.WriteLine("data transakcji to: " + dataTransakcji); dt = DateTime.FromOADate((double)dataTransakcji); dzien = dt.Day.ToString(); miesiac = dt.Month.ToString(); cellValueKwota = valKwota.ToString(); } } r.Cells[wierszPoczatkowy, 8] = "ok"; objWorkbook.Save(); objWorkbook.Close(true, @"C:\Documents and Settings\Administrator\Pulpit\Selenium\wszystkieSeba2.xls", true); objExcel.Quit(); Why after finish test I'm still having excel in process (it does'nt close) And : is there something I can improve to better perfomance ??

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >