Daily Archives

Articles indexed Thursday May 6 2010

Page 25/118 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • In Javascript, is it true that function aliasing works as long as the function being aliased doesn't

    - by Jian Lin
    In Javascript, if we are aliasing a function, such as in: f = g; f = obj.display; obj.f = foo; all the 3 lines above, they will work as long as the function / method on the right hand side doesn't touch this? Since we are passing in all the arguments, the only way it can mess up is when the function / method on the right uses this? Actually, line 1 is probably ok if g is also a property of window? If g is referencing obj.display, then the same problem is there. In line 2, when obj.display touches this, it is to mean the obj, but when f() is invoked, the this is window, so they are different. In line 3, it is the same: when f() is invoked inside of obj's code, then the this is obj, while foo might be using this to refer to window if it were a property of window. (global function). So line 2 can be written as f = function() { obj.display.apply(obj, arguments) } and line 3: obj.f = function() { foo.apply(window, arguments) } Is this the correct method, and are there there other methods besides this?

    Read the article

  • Create setup file automatically uninstall existing setup and install new setupfile without changing

    - by sankar.cs
    Hi.. By setting the bellow properties we can create the setup file automatically uninstall existing setup and install new setupfile. DetectNewerInstalledVersion:True RemovePreviousVersion:True But each and every setup file we need to change the version property of Setupfile. If it is, it won't through error while installing current setupfile otherwise it throws error: already installed. I am looking into how we can create the setup file without changing the version property of existing setupfile. Thanks.

    Read the article

  • Error on writing data to DVD

    - by sijith
    Hi, From past 1 week i stuck on this please help me i am attaching code. bool DVDBurner::Burner() { m_hResult = CoCreateInstance(__uuidof(MsftDiscFormat2Data), NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiscFormat2Data), (void**)&m_discFormatData); if (!SUCCEEDED(m_hResult)) { qDebug()<<"Unable to Initialize IDiscFormat2Data "; return false; } m_hResult = CoCreateInstance(__uuidof(MsftDiscRecorder2), NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiscRecorder2), (void**)&m_discRecorder); if (FAILED(m_hResult)) { qDebug()<<"Unable to Initialize IDiscRecorder2 Data "; return false; } BSTR bstrDeviceName; HRESULT hr = S_OK; BOOL bComInitialised; UINT iCounter = 0; LONG lValue = 0; LONG iCount; bComInitialised = SUCCEEDED(CoInitializeEx(0, COINIT_MULTITHREADED)); // Create an object of IDiscMaster2 if (SUCCEEDED(hr)){ CoCreateInstance( CLSID_MsftDiscMaster2, NULL, CLSCTX_ALL, IID_PPV_ARGS(&discMaster) ); if(FAILED(hr)){ qDebug()<<"\nUnsuccessful in creating an instance of CLSID_MsftDiscMaster2.\n\nError returned: 0x%x\n"<<hr; return 0; } } /////////////////////////// Get the number of drives/////////////////////////////// if (SUCCEEDED(hr)){ hr = discMaster->get_Count(&lValue); if (SUCCEEDED(hr)){ printf("lValue %d\n\n",lValue); } } ////////////////////////// Print all the optical drives attached to the system//// if (SUCCEEDED(hr)){ for(iCount = 0; iCount < lValue; iCount++) { hr = discMaster->get_Item(iCount, &bstrDeviceName); qDebug()<<"\nUnique identifier of the disc device associated with index"<< iCount<< bstrDeviceName; } } m_hResult = m_discRecorder->InitializeDiscRecorder(bstrDeviceName); if (!SUCCEEDED(m_hResult)) { qDebug()<<"IDiscFormat2Data->InitializeDiscRecorder Failed "; return false; } LPCWSTR pszFile=L"D:\\Test\\output.txt"; ULONGLONG mediaSize = 0; mediaSize=GetSizeOnDisc(pszFile); IStream* dataStream = NULL; if (dataStream == NULL) { SHCreateStreamOnFileEx(pszFile, STGM_READ|STGM_SHARE_DENY_NONE|STGM_DELETEONRELEASE, FILE_ATTRIBUTE_NORMAL, FALSE,NULL, &dataStream); } m_hResult = m_discFormatData->put_Recorder(GetInterface()); if (!SUCCEEDED(m_hResult)) { qDebug()<<"IDiscFormat2Data->put_Recorder Failed ";return false;} char *ansistr = "DVDBurner"; int a = lstrlenA(ansistr); BSTR unicodestr = SysAllocStringLen(NULL, a); ::MultiByteToWideChar(CP_ACP, 0, ansistr, a, unicodestr, a); m_hResult = m_discFormatData->put_ClientName(unicodestr); if (FAILED(m_hResult)){qDebug()<<"Unable to put_ClientName(buf_bstr)";return false;} m_hResult = m_discFormatData->Write(dataStream); // Here i am getting error 0xc0aa0403 if (FAILED(m_hResult)){printf("Unable to m_discFormatData- >Write::::Error:0x%08x",m_hResult); return false;} discMaster->Release(); CoUninitialize(); bComInitialised = FALSE; return 0; } ULONGLONG DVDBurner::GetSizeOnDisc(LPCWSTR pszFile) { CFileStatus status; if (CFile::GetStatus(pszFile, status)) { if (status.m_size > 0) { return ((status.m_size / SECTOR_SIZE) + 1) * SECTOR_SIZE; } } return 0; }

    Read the article

  • Change Image in Resources at Runtime

    - by zaidwaqi
    Hi, My understanding of Resources is that I can combine resources i.e. images and my program into single executable. Let's say I have image pic1.png and I put it into Resource of my project, and is accessible with Properties.Resource.pic1. For example, PictureBox pb = new PictureBox(); pb.Image = Properties.Resource.pic1; What I want to do is for that my program will be able to replace this image at runtime. For example, my program runs, and locate newPicture.png, and use this new image to replace pic1.png that was originally used. Maybe my question is better reworded as "Can I include new image into Resources at runtime?" Please help. Thanks.

    Read the article

  • UIPopOver from MKAnnotation callout

    - by Nithin
    Hi all, i'm developing an application for iPad. I have a mapview with several annotations. I need to show a pop-over when the accessory callout method is called, so that the arrow of the popover will point towards the annotation. I am trying to use 'initWithRect' method of the popover, but i'm not getting the co-ordinates(the CGRect in view) of the annotation correctly. How can i get the co-ordinates of an annotation? I need to find out the location of that annotation in the view.

    Read the article

  • socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access

    - by Sean Ochoa
    Hello all. I'm trying to create a custom TCP stack using Python 2.6.5 on Windows 7 to serve valid http page requests on port 80 locally. But, I've run into a snag with what seems like Windows 7 tightened up security. This code worked on Vista. Here's my sample code: import SocketServer class MyTCPHandler(SocketServer.BaseRequestHandler): def handle(self): headerText = """HTTP/1.0 200 OK Date: Fri, 31 Dec 1999 23:59:59 GMT Content-Type: text/html Content-Length: 1354""" bodyText = "<html><body>some page</body></html>" self.request.send(headerText + "\n" + bodyText) if __name__ == "__main__": HOST, PORT = "localhost", 80 server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) server.serve_forever() C:\pythonpython TestServer.py Traceback (most recent call last): File "TestServer.py", line 19, in server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) File "C:\Python26\lib\SocketServer.py", line 400, in init self.server_bind() File "C:\Python26\lib\SocketServer.py", line 411, in server_bind self.socket.bind(self.server_address) File "", line 1, in bind socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions How exactly do I get this to work on Windows 7?

    Read the article

  • Iterating through a range of dates in Python

    - by ShawnMilo
    This is working fine, but I'm looking for any feedback on how to do it better. Right now I think it's better than nested loops, but it starts to get Perl-one-linerish when you have a generator in a list comprehension. Any suggestions are welcome. day_count = (end_date - start_date).days + 1 for single_date in [d for d in (start_date + timedelta(n) for n in range(day_count)) if d <= end_date]: print strftime("%Y-%m-%d", single_date.timetuple()) Notes: I'm not actually using this to print; that's just for demo purposes. The variables start_date and end_date are datetime.date objects, because I don't need the timestamps (they're going to be used to generate a report). I checked the StackOverflow questions which were similar before posting this, but none were exactly the same. Sample Output (for a start date of 2009-05-30 and an end date of 2009-06-09): 2009-05-30 2009-05-31 2009-06-01 2009-06-02 2009-06-03 2009-06-04 2009-06-05 2009-06-06 2009-06-07 2009-06-08 2009-06-09

    Read the article

  • Protect individual sites on Ubuntu/Apache server

    - by Christoffer
    Hi,?? I need to set up a Apache server configuration for some client sites that run under the same Ubuntu 9.10 machine. All sites are allowed to run PHP, Python and Ruby on Rails. I do not control the source code of these sites and so I need to set up a filter in order to prevent one user to reach files on another users account.?? If I run a script to list files in "/" from one account, I can browse some files and directories in the actual server root. I want to set the root for each account to /var/usersite.com/www/ instead so that listing files in "/" shows the files in the client's root. ??How is this most easily configured??? Cheers!? /Christoffer

    Read the article

  • How To Customize Wallpaper in Windows 7 Starter Edition

    - by Asian Angel
    If you have the Starter Edition of Windows 7 installed on your netbook you may be sick of looking at the default wallpaper. With Starter Background Changer you can access other customization options with ease. Before There is not a lot that you can say about the singular default wallpaper included with the Starter Edition…it just kind of sits there all boring like. Installing Starter Background Changer Since the installer part of the program is in French we have the entire set of install windows shown here with the appropriate buttons highlighted to get you through the whole process without any problems. Using Starter Background Changer Once the installation process has finished you will simply see a quiet screen with no desktop icons or Start Menu entries visible. Now if you are wondering at this point “Did the program finish installing or did it install at all?” the answer is yes. Right click on your desktop and you will notice a new entry on the Context Menu…the same one that is included in the other editions but not Starter. Time to have some fun… The Personalization Window will open maximized but we have reduced it here for our screenshots. You have four regular categories to choose from in the lower part of the window: Wallpaper, Colors, Sounds, & Screensavers. The first category that we chose for our example was Wallpaper. As you can see here the main display area (My Collection) has no wallpapers showing at the moment. You can use the drop-down menu to access your My Pictures Folder or browse for a different location. Notice that you can choose how the image fills the screen and set up a timed wallpaper slideshow at the bottom. Any picture (or pictures) selected will be added to the My Collection display for easy access the next time you open the window. Once you choose a picture click on Validate the modification to set the wallpaper for your desktop and return to the main window. When you return to the main window you will see a preview for your selection. At this point you can simply close the window or make further adjustments in the other categories. Starter Background Changer provides easy one-stop access to other customization areas. We started off with Colors… Followed by Sounds… And finally Screensavers. Before you do close the main window you can take a quick look at the Options if desired. We did set Optimization of the images to High on our system. Quick and easy wallpaper satisfaction. We did pin the Program Window to our Taskbar…nice if you prefer this method as opposed to the Desktop Context Menu. Conclusion If you have been longing for a way to change the wallpaper in Windows 7 Starter Edition then you will definitely want to give this program a try. Goodbye boring default wallpaper! For more wonderful ways to customize your Windows 7 Started Edition be sure to read our article here. Links Download Starter Background Changer Similar Articles Productive Geek Tips Awesome Desktop Wallpapers: The Windows 7 EditionWindows 7 Welcome Screen Taking Forever? Here’s the Fix (Maybe)Desktop Fun: Starship Theme WallpapersDesktop Fun: Starscape Theme WallpapersDesktop Fun: Fantasy Theme Wallpapers TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips DVDFab 6 Revo Uninstaller Pro Registry Mechanic 9 for Windows PC Tools Internet Security Suite 2010 Office 2010 reviewed in depth by Ed Bott FoxClocks adds World Times in your Statusbar (Firefox) Have Fun Editing Photo Editing with Citrify Outlook Connector Upgrade Error Gadfly is a cool Twitter/Silverlight app Enable DreamScene in Windows 7

    Read the article

  • PyQt - QLabel inheriting

    - by Ockonal
    Hello, i wanna inherit QLabel to add there click event processing. I'm trying this code: class NewLabel(QtGui.QLabel): def __init__(self, parent): QtGui.QLabel.__init__(self, parent) def clickEvent(self, event): print 'Label clicked!' But after clicking I have no line 'Label clicked!' EDIT: Okay, now I'm using not 'clickEvent' but 'mousePressEvent'. And I still have a question. How can i know what exactly label was clicked? For example, i have 2 edit box and 2 labels. Labels content are pixmaps. So there aren't any text in labels, so i can't discern difference between labels. How can i do that? EDIT2: I made this code: class NewLabel(QtGui.QLabel): def __init__(self, firstLabel): QtGui.QLabel.__init__(self, firstLabel) def mousePressEvent(self, event): print 'Clicked' #myLabel = self.sender() # None =) self.emit(QtCore.SIGNAL('clicked()'), "Label pressed") In another class: self.FirstLang = NewLabel(Form) QtCore.QObject.connect(self.FirstLang, QtCore.SIGNAL('clicked()'), self.labelPressed) Slot in the same class: def labelPressed(self): print 'in labelPressed' print self.sender() But there isn't sender object in self. What i did wrong?

    Read the article

  • How to use more parameters in help-ballon grails-plugin

    - by servicesskurt
    I try to use more of the parameters but could not get it working with <g:helpBalloon title="foo" content="bla" useEvent="['mouseover']" /> should result in <script type="text/javascript"> new HelpBalloon({ title: 'foo', content: 'bla', useEvent: ['mouseover'] }); </script> but useEvent="['mouseover']" seems not to be recognized?! as seen on http://www.beauscott.com/examples/help_balloons/doc/examples.htm

    Read the article

  • Most Elegant Way to write isPrime in java

    - by Anantha Kumaran
    public class Prime { public static boolean isPrime1(int n) { if (n <= 1) { return false; } if (n == 2) { return true; } for (int i = 2; i <= Math.sqrt(n) + 1; i++) { if (n % i == 0) { return false; } } return true; } public static boolean isPrime2(int n) { if (n <= 1) { return false; } if (n == 2) { return true; } if (n % 2 == 0) { return false; } for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) { if (n % i == 0) { return false; } } return true; } } public class PrimeTest { public PrimeTest() { } @Test public void testIsPrime() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Prime prime = new Prime(); TreeMap<Long, String> methodMap = new TreeMap<Long, String>(); for (Method method : Prime.class.getDeclaredMethods()) { long startTime = System.currentTimeMillis(); int primeCount = 0; for (int i = 0; i < 1000000; i++) { if ((Boolean) method.invoke(prime, i)) { primeCount++; } } long endTime = System.currentTimeMillis(); Assert.assertEquals(method.getName() + " failed ", 78498, primeCount); methodMap.put(endTime - startTime, method.getName()); } for (Entry<Long, String> entry : methodMap.entrySet()) { System.out.println(entry.getValue() + " " + entry.getKey() + " Milli seconds "); } } } I am trying to find the fastest way to check whether the given number is prime or not. This is what is finally came up with. Is there any better way than the second implementation(isPrime2).

    Read the article

  • Excel automation: Close event missing

    - by chiccodoro
    Another hi all, I am doing Excel automation via Interop in C#, and I want to be informed when a workbook is closed. However, there is no Close event on the workbook nor a Quit event on the application. Has anybody done that before? How can I write a piece of code which reacts to the workbook being closed (which is only executed if the workbook is really closed)? Ideally that should happen after closing the workbook, so I can rely on the file to reflect all changes. Details about what I found so far: There is a BeforeClose() event, but if there are unsaved changes this event is raised before the user being asked whether to save them, so at the moment I can process the event, I don't have the final file and I cannot release the COM objects, both things that I need to have/do. I do not even know whether the workbook will actually be closed, since the user might choose to abort closing. Then there is a BeforeSave() event. So, if the user chooses "Yes" to save unsaved changes, then BeforeSave() is executed after BeforeClose(). However, if the user chooses to "Abort", then hits "file-save", the exact same order of events is executed. Further, if the user chooses "No", the BeforeSave() isn't executed at all. The same holds as long as the user doesn't click any of these options.

    Read the article

  • java.sql.SQLException: OALL8 is in an inconsistent state On weblogic 9

    - by user179056
    Hello, We are getting this error "java.sql.SQLException: OALL8 is in an inconsistent state " when executing our web app on weblogic 9. The jdk used is 1.5 and database is Oracle10.2g We have switched out oracle drivers ojdbc14.jar with ojdbc5.jar. We have also added orai18n.jar. We have ensured that this change of jar occurs with the web app library as well as other weblogic server classpaths where ojdbc14.jar existed. The problem persists Any pointers would help regards Sameer

    Read the article

  • Can you tell me why this generates time limit exceeded in spoj(Prime Number Generator)

    - by magiix
    #include<iostream> #include<string.h> #include<math.h> using namespace std; bool prime[1000000500]; void generate(long long end) { memset(prime,true,sizeof(prime)); prime[0]=false; prime[1]=false; for(long long i=0;i<=sqrt(end);i++) { if(prime[i]==true) { for(long long y=i*i;y<=end;y+=i) { prime[y]=false; } } } } int main() { int n; long long b,e; scanf("%d",&n); while(n--) { cin>>b>>e; generate(e); for(int i=b;i<e;i++) { if(prime[i]) printf("%d\n",i); } } return 0; } That's my code for spoj prime generator. Altought it generates the same output as another accepted code ..

    Read the article

  • how to do server side form validation for dynamic inputs with Django

    - by Satoru.Logic
    Hi, all. I am using django.forms.Form to validate form data in a survey applications. In a survey-creating form, a user can submit multiple questions that belong to the survey being created. Names for the question inputs are in the form of 'question_seq' , where seq is maintained using Javascript. Back in the server side, my code doesn't know before hand how many such questions will be submitted. Is there any way to do this with Django form so that the form can automatically recognizes the questions and validate them?

    Read the article

  • Eliminate subquery for average numeric value

    - by Dave Jarvis
    Quest A query selects locations that begin with Vancouver, which are in a 5 minute radius from one another. SQL Code The following SQL abomination does the trick: SELECT NAME FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%' AND LATITUDE BETWEEN (SELECT round((min(LATITUDE) + max(LATITUDE)) / 2)-5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') and (SELECT round((min(LATITUDE) + max(LATITUDE)) / 2)+5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') AND LONGITUDE BETWEEN (SELECT round((min(LONGITUDE) + max(LONGITUDE)) / 2)-5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') and (SELECT round((min(LONGITUDE) + max(LONGITUDE)) / 2)+5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') ORDER BY LATITUDE Question How can this query be simplified to remove the redundancy, without using a view? Restrictions The database is MySQL, but ANSI SQL is always nice. Thank you!

    Read the article

  • Safely turning a JSON string into an object

    - by Matt Sheppard
    Given a string of JSON data, how can you safely turn that string into a JavaScript object? Obviously you can do this unsafely with something like... var obj = eval("(" + json + ')'); ...but that leaves us vulnerable to the json string containing other code, which it seems very dangerous to simply eval.

    Read the article

  • how to hide the image? how can i do ?

    - by user309381
    function Psend() { new Ajax.Request('Handler.ashx', { method: 'get', onSuccess: function(transport) { var response = transport.responseText || "no response text"; //alert("Success! \n\n" + response); var obj = response.evalJSON(true); for (i = 0; i < 4; i++) { DeCheBX = $('MyDiv').insert(new Element('input', { 'type': 'checkbox', 'id': "img" + obj[i].Nam, 'value': obj[i].IM, 'onClick': 'SayHi(this)' })); DeImg = $('MyDiv').insert(new Element('img', { 'id': "img" + obj[i].Nam, 'src': obj[i].IM, 'style': 'display = inline', 'onClick': 'Say(this)' })); document.body.appendChild(DeCheBX); document.body.appendChild(DeImg); } }, onFailure: function() { alert('Something went wrong...') } }); SayHi = function(x) { if ($(x).checked == true) { // $('id').hide(); **$('img'+i).style.visibility = "hidden";**// doesnt work } };

    Read the article

  • printing out prime numbers from array

    - by landscape
    I'd like to print out all prime numbers from an array with method. I can do it with one int but don't know how to return certain numbers from array. Thanks for help! public static boolean isPrime(int [] tab) { boolean prime = true; for (int i = 3; i <= Math.sqrt(tab[i]); i += 2) if (tab[i] % i == 0) { prime = false; break; } for(int i=0; i<tab.length; i++) if (( tab[i]%2 !=0 && prime && tab[i] > 2) || tab[i] == 2) { return true; } else { return false; } //return prime; } thanks both of you. Seems like its solved: public static void isPrime(int[] tab) { for (int i = 0; i < tab.length; i++) { if (isPrimeNum(tab[i])) { System.out.println(tab[i]); } } } public static boolean isPrimeNum(int n) { boolean prime = true; for (long i = 3; i <= Math.sqrt(n); i += 2) { if (n % i == 0) { prime = false; break; } } if ((n % 2 != 0 && prime && n > 2) || n == 2) { return true; } else { return false; } }

    Read the article

  • biginteger calculation problem

    - by murali
    I am using the following code but the parameters are not passed to the methods. BigInteger p = BigInteger.valueOf(0); BigInteger u1 = obj.bigi_calc(g1, l); In this g1,l are long values. The method is private BigInteger bigi_calc(long g1, long l){ BigInteger cal = BigInteger.valueOf(g1); BigInteger cal1= BigInteger.valueOf(l); for(BigInteger f = BigInteger.ONE;f.compareTo(cal1)>0;f=f.add(BigInteger.ONE)){ //BigInteger p= BigInteger.valueOf(0); p = cal.multiply(cal1); System.out.println("check p"+p); } // System.out.println("check p"+p); return p; } The elipse shows that it may be out of sync, but the parameters are not passed to the functions. Can you please help me to solve this problem?

    Read the article

  • How can I prevent users from overriding the total cost in a shopping cart, when submitted as a hidde

    - by Gobi
    I'm having serious problems with accepting payments. I'm passing the total amount in a hidden field <input type="hidden" name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-1.price" value="129.00"/> Some of the users changed this value to 2 using firebug and submitted the form. Instead of getting $129, we only received $2. I have no idea how to proceed this anyone help me quick .

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >