Daily Archives

Articles indexed Sunday January 2 2011

Page 25/27 | < Previous Page | 21 22 23 24 25 26 27  | Next Page >

  • Tell Xcode to ignore a header for some targets?

    - by William Jockusch
    I have an Xcode project with a mac target and an iOS target. The project contains a class IPhoneOnlyClass which is used in the iOS target only. I have unchecked IPhoneOnlyClass.m from the mac target so it doesn't compile that file. Now IphoneOnlyClass.h contains the line #import <GameKit/GameKit.h> When I am compiling for the mac target, Xcode gives me an error: error: GameKit/GameKit.h: No such file or directory I could get around this with a #ifdef, but is there a better way? I'd rather tell Xcode to ignore the header altogether when compiling the mac target.

    Read the article

  • accessing ok.DialogResult inside a function

    - by sayyad
    I am writing function which accepts user input from textbox. Action will take place when ok button is clicked. i made button(DialogResult=OK). code looks like private void canny() { // if (this.DialogResult == DialogResult.OK) { MessageBox.Show("ok"); } //to Do } But I can't see any messagebox. What I am missing. private void ok_Click(object sender, EventArgs e) { // should I add here some thing } Should I add control Form1.Control.Add(Ok)?????????????????? if yes in which part of code. regards,

    Read the article

  • Updating your DotNetNuke Copyright Statement for 2011, and beyond

    - by Chris Hammond
    originally posted on my DotNetNuke.com blog Every January people start thinking “oh crap, I need to update the copyright statement on my website”. And everyone runs out and makes the change to the current year. Well, if you use DotNetNuke you can easily change the Copyright statement on your site from the Site Settings page, found under the Admin menu. You’ll find a setting like the following. If your Skin in DotNetNuke uses the Copyright SkinObject then changing that setting and updating the settings...(read more)

    Read the article

  • Using "enterprise" switches in home network?

    - by Industrial
    Hi everyone, After more than 12 years working with computers, I am still way behind when it comes to networking, so please bear with me :) As of this Christmas, the number of computers in my home has increased and it's well about time to upgrade the current network hardware in order to offer LAN connection to all computers. Trying to find a cheap solution, A close friend offered me a great deal on a "enterprise-class" Switch from HP (more LAN ports than I would ever need), at the same price as what a brand new Netgear or D-link Switch with 6/8 ports would cost me in retail. Would it be common sense to get this one and start using it immediately and never again have to worry about running out of LAN connections, or am I taking on a bigger bite than what I could chew?

    Read the article

  • How to setup stunnel so that gmail can use my own smtp server to send messages.

    - by igorhvr
    I am trying to setup gmail to send messages using my own smtp server. I am doing this by using stunnel over a non-ssl enabled server. I am able to use my own smtp client with ssl enabled just fine to my server. Unfortunately, however, gmail seems to be unable to connect to my stunnel port. Gmail seems to be simply closing the connection right after it is established - I get a "SSL socket closed on SSL_read" on my server logs. On gmail, I get a "We are having trouble authenticating with your other mail service. Please try changing your SSL settings. If you continue to experience difficulties, please contact your other email provider for further instructions." message. Any help / tips on figuring this out will be appreciated. My certificate is self-signed - could this perhaps be related to the problem I am experiencing? I pasted the entire SSL session (logs from my server) below. 2011.01.02 16:56:20 LOG7[20897:3082491584]: Service ssmtp accepted FD=0 from 209.85.210.171:46858 2011.01.02 16:56:20 LOG7[20897:3082267504]: Service ssmtp started 2011.01.02 16:56:20 LOG7[20897:3082267504]: FD=0 in non-blocking mode 2011.01.02 16:56:20 LOG7[20897:3082267504]: Option TCP_NODELAY set on local socket 2011.01.02 16:56:20 LOG7[20897:3082267504]: Waiting for a libwrap process 2011.01.02 16:56:20 LOG7[20897:3082267504]: Acquired libwrap process #0 2011.01.02 16:56:20 LOG7[20897:3082267504]: Releasing libwrap process #0 2011.01.02 16:56:20 LOG7[20897:3082267504]: Released libwrap process #0 2011.01.02 16:56:20 LOG7[20897:3082267504]: Service ssmtp permitted by libwrap from 209.85.210.171:46858 2011.01.02 16:56:20 LOG5[20897:3082267504]: Service ssmtp accepted connection from 209.85.210.171:46858 2011.01.02 16:56:20 LOG7[20897:3082267504]: FD=1 in non-blocking mode 2011.01.02 16:56:20 LOG6[20897:3082267504]: connect_blocking: connecting 127.0.0.1:25 2011.01.02 16:56:20 LOG7[20897:3082267504]: connect_blocking: s_poll_wait 127.0.0.1:25: waiting 10 seconds 2011.01.02 16:56:20 LOG5[20897:3082267504]: connect_blocking: connected 127.0.0.1:25 2011.01.02 16:56:20 LOG5[20897:3082267504]: Service ssmtp connected remote server from 127.0.0.1:3701 2011.01.02 16:56:20 LOG7[20897:3082267504]: Remote FD=1 initialized 2011.01.02 16:56:20 LOG7[20897:3082267504]: Option TCP_NODELAY set on remote socket 2011.01.02 16:56:20 LOG5[20897:3082267504]: Negotiations for smtp (server side) started 2011.01.02 16:56:20 LOG7[20897:3082267504]: RFC 2487 not detected 2011.01.02 16:56:20 LOG5[20897:3082267504]: Protocol negotiations succeeded 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): before/accept initialization 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read client hello A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write server hello A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write certificate A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write certificate request A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 flush data 2011.01.02 16:56:20 LOG5[20897:3082267504]: CRL: verification passed 2011.01.02 16:56:20 LOG5[20897:3082267504]: VERIFY OK: depth=2, /C=US/O=Equifax/OU=Equifax Secure Certificate Authority 2011.01.02 16:56:20 LOG5[20897:3082267504]: CRL: verification passed 2011.01.02 16:56:20 LOG5[20897:3082267504]: VERIFY OK: depth=1, /C=US/O=Google Inc/CN=Google Internet Authority 2011.01.02 16:56:20 LOG5[20897:3082267504]: CRL: verification passed 2011.01.02 16:56:20 LOG5[20897:3082267504]: VERIFY OK: depth=0, /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read client certificate A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read client key exchange A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read certificate verify A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read finished A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write change cipher spec A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write finished A 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 flush data 2011.01.02 16:56:20 LOG7[20897:3082267504]: 1 items in the session cache 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 client connects (SSL_connect()) 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 client connects that finished 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 client renegotiations requested 2011.01.02 16:56:20 LOG7[20897:3082267504]: 1 server connects (SSL_accept()) 2011.01.02 16:56:20 LOG7[20897:3082267504]: 1 server connects that finished 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 server renegotiations requested 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 session cache hits 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 external session cache hits 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 session cache misses 2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 session cache timeouts 2011.01.02 16:56:20 LOG6[20897:3082267504]: SSL accepted: new session negotiated 2011.01.02 16:56:20 LOG6[20897:3082267504]: Negotiated ciphers: RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5 2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL socket closed on SSL_read 2011.01.02 16:56:20 LOG7[20897:3082267504]: Socket write shutdown 2011.01.02 16:56:20 LOG5[20897:3082267504]: Connection closed: 167 bytes sent to SSL, 37 bytes sent to socket 2011.01.02 16:56:20 LOG7[20897:3082267504]: Service ssmtp finished (0 left)

    Read the article

  • Waiting for a daemontools service to stop

    - by also
    I'm running a service under daemontools that take several seconds to stop when sent the TERM signal. I need to stop it in a script, and then wait for the process to stop before continuing to take a LVM snapshot or restarting the service. Does daemontools provide a way to do this? If not, what's the best way? I was thinking of sleeping while svcok exits with 0, but it seems like this should be a common problem with an easier solution. Thoughts?

    Read the article

  • Mac OS X duplex printing problem: one- vs. multi-paged documents

    - by Christian Lindig
    I like to print on pre-printed stationery using the Preview.app and a duplex-capable HP Color Laserjet 4700 (PostScript) printer. The print dialog handles one and two-paged documents differently: the paper needs to be placed differently into the tray if the document contains one page versus when it contains two pages. This is not obvious when printing on plain paper but becomes obvious when front and reverse side of sheets are marked. Otherwise the first page would end up on the reverse side of the first sheet. I believe the problem is caused by the printer driver setting duplex printing to false (using the PostScript setpagedevice operator) when emitting a single-page document versus keeping it set to true when emitting multi-page documents. All this despite that duplex printing is always specified in the printer dialog. When printing a single-sided document, duplex=true and duplex=false seem to make a difference with respect which side of a sheet gets printed on. It would be also helpful if others could confirm the problem actually exists. I suspect this problem is not limited to specific printers. I'm on OS X 10.6 and I checked two different HP printers.

    Read the article

  • Finding a shared HDD attached to the network from my F-13 machine

    - by Ramy
    Sorry for the slew of n00bie questions, but here is one more. I recently partitioned my 1.5TB harddrive according to this question I then bought this to attach the harddrive to my network. The problem is, how do I navigate to the hard drive to move files over the network to the HDD. should this be moved to serverfault? update: the disk isn't even showing up when i call "fdisk -l" (as root). How can I mount it if I can't even find it? [root@Moonface ~]# /sbin/fdisk -l Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00018598 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 19458 155777024 8e Linux LVM Disk /dev/dm-0: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/dm-0 doesn't contain a valid partition table Disk /dev/dm-1: 4764 MB, 4764729344 bytes 255 heads, 63 sectors/track, 579 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/dm-1 doesn't contain a valid partition table Disk /dev/dm-2: 101.0 GB, 101032394752 bytes 255 heads, 63 sectors/track, 12283 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/dm-2 doesn't contain a valid partition table

    Read the article

  • External HDD incorrectly detected as internal - how change to enable hot swap/eject?

    - by Sam
    Hi All, I have win 7 x64 Home Prem. The HDD is a seagate barracuda, 7200.7 ST3120827AS. 3.5", Serial: 3ms006n6, Firmware: 3.42 (no further updates) NexStar CX External case (drivers installed). I have three drives: WD320 with OS installed WD750 data storage (internal) seagate 120 (external) - connected via esata board connected to sata on motherboard (MSI p43 neo) Tried uninstalling HDD in device manager to no effect. Also the internal WD750 is detected as an external drive and win taskbar icon allows for it to be ejected (unlike the seagate). All drives are configured - Online, Simple, Basic, NTFS, Active, Primary Partition (except c drive). The seagate was previously used as a primary disk with XP operating system so I deleted the volume and created/reformatted (not quick). HDD is no longer "Active". But did not fix problem. Background Originally, I installed win 7 with the bios set to IDE and forgot to install the chipset drivers. Then I changed win 7 to install the AHCI drivers, changed the bios to AHCI and rebooted. Win 7 loaded drivers but WD HDD gave problems/crashed. I installed chipset drivers and latest intell storage matrix software thingie (in safe mode). Everything worked fine after that except for the problem of not corrrectly detecting the external drive] I have noticed that under the driver properties (and similarly in the registry) the two drives are configured differently (e.g. in driver details property capabilities for the WD the value is set to 0000006, CM_DEVCAP_REMOVABLE & EJECTSUPPORTED - whereas the seagate shows 0000080 & CM_DEVCAP_SURPRISEREMOVALOK). Any easy way to configure things? I tried physically swapping the sata connections on the mainboard without success So far I have found that a solution to my problem might be to perform some reg changes: http://superuser.com/questions/12955/how-do-i-remove-the-option-to-eject-sata-drives-from-the-windows-7-tray-icon

    Read the article

  • How to avoid ugly dithering when running KDE over VNC?

    - by Chris Jester-Young
    I'm currently setting up a new Xen paravirt domain running KDE (4.2.2, from Kubuntu 9.04). As I have been unable to get the virtual framebuffer working in it, I've decided to set up VNC (from the vnc4server package), and run KDE over Xvnc. This is all fine and good, and KDE starts up okay. However, all the colours look dithered, especially on the task bar and title bar, making them impossible to see. From my web searches, it appears to be because these items are drawn using Porter-Duff. This is especially the case when using the Oxygen style, and Oxygen and Ozone window titlebars (selecting these styles generates messages about Porter-Duff being unavailable); not using those styles at least makes most of the UI widgets and window titles usable again. But this doesn't solve the problem for the task bar, nor for the desktop, where the only theme available to me is Oxygen (this is under the "Desktop Settings - Plasma Workspace" window, just for reference). So, unless I have a way to use a non-Porter-Duff theme for those, it seems that KDE would still be unusable under VNC. So if someone experienced with KDE can advise on how to work around, or even fix, these issues, I'd appreciate it very much. :-)

    Read the article

  • Should debug code be left in place, always, or added only when debugging and removed when the bug has been found?

    - by gablin
    I, for one, only add debug code (such as print statements) when I'm trying to locate a bug. And once I've found it, I remove the debug code (and add a test case which specifically tests for that bug). I feel that it's cluttering the real code and therefore has no place there unless I'm debugging. How do you do it? Do you leave the debug code in place, or remove it when obsolete (which may be difficult to judge when that is)?

    Read the article

  • Donald Ferguson says end-user programming is next big thing. Is it?

    - by Joris Meys
    You can guess how I came to ask this question... Anyway : http://www.bbc.co.uk/news/business-11944966 Donald Ferguson claiming that his websphere was his biggest disaster and proclaiming that end-user programming will be the way forward. This genuinely spurs the question : what with current programming languages. Honestly, I don't think that end-user programming will go much beyond a rather rigid template where you can build some apps around. If you see how many people actually manage to understand the basic functionality of functions in EXCEL... Plus, I fail to see how complex and performant systems can be built in such an end-user programming language ( Visual Basic, anyone?) Nice to play around with, but for many applications they're just not the thing. So no worries for the old languages if you ask me. What's your ideas?

    Read the article

  • Return to the old C days.

    - by RPK
    Long back I used to program on C and than VB exploitation changed the career path. After VB came the .NET that proved to be a HoneyPot of Microsoft for old VB programmers and frustrated programmers of other hard to learn languages. The label on this HoneyPot was: "Getting things done." I now want to contribute to the Linux and other GNU projects. I feel whatever programming language you learn today, but if programming is your bread-and-butter, you must remain in touch with C. Many things have changed now. From the old Turbo-C for DOS to the present ...? Please advise me how to get back on the C track again. Reading again whole thing, chapter-by-chapter is not possible now, but I can learn by writing small utilities type of things, but sure GUI based. And yes, I hope, learning is going to be easy now with so many live forums and active community spots like StackOverflow etc.

    Read the article

  • Do I need to have antivirus software installed on a Linux distro?

    - by Vinaychalluru
    I thought that there was no need to scan for viruses in Ubuntu or any Linux distros until I found a virus scanner package named 'clamtk' and 'klamav' in Ubuntu software center yesterday. This leads to the following questions: How do viruses differ between Linux and Windows? How do the strategies for protection differ between Linux and Windows? Should a virus scanner package be installed on my system? If so, which would be a better option?

    Read the article

  • Problem getting GOBI 2000 HS to work

    - by Zypher
    I've been trying to get my integrated GOBI WWAN card to work under 10.10 for a while now. I was able to get the network manager to see the card after installing the gobi-loader package. I was able to setup the connection, but i cannot establish a connection to Verizon. Below is the output from /var/log/daemon.log as i try to connect. Oct 19 14:29:42 gbeech-x201 AptDaemon: INFO: Quiting due to inactivity Oct 19 14:29:42 gbeech-x201 AptDaemon: INFO: Shutdown was requested Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> Activation (ttyUSB0) starting connection 'Verizon connection' Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> (ttyUSB0): device state change: 3 -> 4 (reason 0) Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> Activation (ttyUSB0) Stage 1 of 5 (Device Prepare) scheduled... Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> Activation (ttyUSB0) Stage 1 of 5 (Device Prepare) started... Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> (ttyUSB0): device state change: 4 -> 6 (reason 0) Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> Activation (ttyUSB0) Stage 1 of 5 (Device Prepare) complete. Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> Activation (ttyUSB0) Stage 1 of 5 (Device Prepare) scheduled... Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> Activation (ttyUSB0) Stage 1 of 5 (Device Prepare) started... Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> (ttyUSB0): device state change: 6 -> 4 (reason 0) Oct 19 14:33:45 gbeech-x201 NetworkManager[1105]: <info> Activation (ttyUSB0) Stage 1 of 5 (Device Prepare) complete. Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <warn> CDMA connection failed: (32) No service Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <info> (ttyUSB0): device state change: 4 -> 9 (reason 0) Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <info> Marking connection 'Verizon connection' invalid. Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <warn> Activation (ttyUSB0) failed. Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <info> (ttyUSB0): device state change: 9 -> 3 (reason 0) Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <info> (ttyUSB0): deactivating device (reason: 0). Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <info> Policy set 'Auto SO-GUEST' (wlan0) as default for IPv4 routing and DNS. Oct 19 14:34:46 gbeech-x201 NetworkManager[1105]: <info> Policy set 'Auto SO-GUEST' (wlan0) as default for IPv4 routing and DNS.

    Read the article

  • Objective-C and Cocoa : crash when calling a class function without entering the function

    - by Oliver
    Hello, I have a class function (declared and implemented) in a class MyUtils : + (NSString*) theFunction:(NSString*)param1 param2:(NSString*)param2 param3:(NSString*)param3; When I call this function, with : NSString *item = [MyUtils theFunction:@"abc" param2:aPreviousNSString param3:@"xyz"; my app crashes. In the debugger I have a breakpoint on the first action of the "theFunction" function. And this breakpoint is never reached. If I replace the call by NSString *item = @"youyou"; then everything is ok. Forcing a retain on aPreviousNSString before the call does not change anything. Do you have an idea of what is happening ? Thanks

    Read the article

  • Starting out with Objective C; need some guidance

    - by alimaxwell
    Hi Everyone, I have started learning Objective C with no prior programming experience from the 'Become an X-Coder' eBook (http://download.cocoalab.com.s3.amazonaws.com/BecomeAnXcoder.pdf). My question is, if I want to be doing iPhone development, am I going in the right direction? Am I learning the wrong language, or should I be learning Cocoa Touch? As I said, I have no prior experience, and just need someone to point me in the right direction. Apoligies if I have put this in the wrong place. Thanks very much for your time.

    Read the article

  • Jacob + Microsoft SpeechAPI trouble

    - by guai
    Following groovy code kills JVM on SetInterest method invocation It uses Scriptom, the groovy DSL for Jacob Spend whole day searching SAPI's SPFEI macro to rewrite it in groovy. Don't sure does it came out right. Or maybe other bugs %) Help welcomed import org.codehaus.groovy.scriptom.* import static org.codehaus.groovy.scriptom.tlb.sapi.SpeechVoiceSpeakFlags.* import static org.codehaus.groovy.scriptom.tlb.sapi.SpeechRunState.* import static org.codehaus.groovy.scriptom.tlb.sapi.SpeechLib.* import static org.codehaus.groovy.scriptom.tlb.sapi.SPEVENTENUM.* def spfei(Integer[] args) { res = 1<<SPEI_RESERVED1 | 1<<SPEI_RESERVED2 args.each {res |= 1<<it} res } Scriptom.inApartment { def voice = new ActiveXObject('SAPI.SpVoice') evtsrc = voice.toInterface(ISpEventSource) evtsrc.setInterest(spfei(SPEI_WORD_BOUNDARY), spfei(SPEI_WORD_BOUNDARY)) evtsrc.events.Callbacks = {args -> println 'jjj'} voice.speak "Hello, world", SVSFlagsAsync }

    Read the article

  • How to get notified about changes of the history via history.pushState?

    - by Felix Kling
    So now that HTML5 introduces history.pushState to change the browsers history, websites start using this in combination with Ajax instead of changing the fragment identifier of the URL. Sadly that means that those calls cannot be detect anymore by onhashchange. My question is: Is there a reliable way (hack? ;)) to detect when a website uses history.pushState? The specification does not state anything about events that are raised (at least I couldn't find anything). I tried to create a facade and replaced window.history with my own JavaScript object, but it didn't have any effect at all. Further explanation: I'm developing a Firefox add-on that needs to detect these changes and act accordingly. I know there was a similar question a few days ago that asked whether listening to some DOM events would be efficient but I would rather not rely on that because these events can be generated for a lot of different reasons. Update: Here is a jsfiddle (use Firefox 4 or Chrome 8) that shows that onpopstate is not triggered when pushState is called (or am I doing something wrong? Feel free to improve it!). Update 2: Another (side) problem is that window.location is not updated when using pushState (but I read about this already here on SO I think).

    Read the article

  • Creating a nested model form

    - by Elliot
    Hey Guys, I'm trying to build a multi model form - but one of the issues, is I need to link the models within the form. For example, lets say the form I have has the following models: Users, Profiles When creating a new user, I'd like to create a new profile simultaneously, and then link the two. The issue is, if neither have been created yet, they don't have ID's yet - so how can I assign linking values? Thanks! -Elliot

    Read the article

  • Linking two models in a multi-model form

    - by Elliot
    Hey Guys, I have a nested multimodel form right now, using Users and Profiles. Users has_one profile, and Profile belongs_to Users. When the form is submitted, a new user is created, and a new profile is created, but they are not linked (this is the first obvious issue). The user's model has a profile_id row, and the profile's model has a user_id row. Here is the code for the form: <%= form_for(@user, :url => teams_path) do |f| %> <p><%= f.label :email %><br /> <%= f.text_field :email %></p> <p><%= f.label :password %><br /> <%= f.password_field :password %></p> <p><%= f.label :password_confirmation %><br /> <%= f.password_field :password_confirmation %></p> <%= f.hidden_field :role_id, :value => @role.id %></p> <%= f.hidden_field :company_id, :value => current_user.company_id %></p> <%= fields_for @user.profile do |profile_fields| %> <div class="field"> <%= profile_fields.label :first_name %><br /> <%= profile_fields.text_field :first_name %> </div> <div class="field"> <%= profile_fields.label :last_name %><br /> <%= profile_fields.text_field :last_name %> </div> <% end %> <p><%= f.submit "Sign up" %></p> <% end %> A second issue, is even though the username, and password are successfully created through the form for the user model, the hidden fields (role_id & company_id - which are also links to other models) are not created (even though they are part of the model) - the values are successfully shown in the HTML for those fields however. Any help would be great!

    Read the article

  • STL find performs bettern than hand-crafter loop

    - by dusha
    Hello all, I have some question. Given the following C++ code fragment: #include <boost/progress.hpp> #include <vector> #include <algorithm> #include <numeric> #include <iostream> struct incrementor { incrementor() : curr_() {} unsigned int operator()() { return curr_++; } private: unsigned int curr_; }; template<class Vec> char const* value_found(Vec const& v, typename Vec::const_iterator i) { return i==v.end() ? "no" : "yes"; } template<class Vec> typename Vec::const_iterator find1(Vec const& v, typename Vec::value_type val) { return find(v.begin(), v.end(), val); } template<class Vec> typename Vec::const_iterator find2(Vec const& v, typename Vec::value_type val) { for(typename Vec::const_iterator i=v.begin(), end=v.end(); i<end; ++i) if(*i==val) return i; return v.end(); } int main() { using namespace std; typedef vector<unsigned int>::const_iterator iter; vector<unsigned int> vec; vec.reserve(10000000); boost::progress_timer pt; generate_n(back_inserter(vec), vec.capacity(), incrementor()); //added this line, to avoid any doubts, that compiler is able to // guess the data is sorted random_shuffle(vec.begin(), vec.end()); cout << "value generation required: " << pt.elapsed() << endl; double d; pt.restart(); iter found=find1(vec, vec.capacity()); d=pt.elapsed(); cout << "first search required: " << d << endl; cout << "first search found value: " << value_found(vec, found)<< endl; pt.restart(); found=find2(vec, vec.capacity()); d=pt.elapsed(); cout << "second search required: " << d << endl; cout << "second search found value: " << value_found(vec, found)<< endl; return 0; } On my machine (Intel i7, Windows Vista) STL find (call via find1) runs about 10 times faster than the hand-crafted loop (call via find2). I first thought that Visual C++ performs some kind of vectorization (may be I am mistaken here), but as far as I can see assembly does not look the way it uses vectorization. Why is STL loop faster? Hand-crafted loop is identical to the loop from the STL-find body. I was asked to post program's output. Without shuffle: value generation required: 0.078 first search required: 0.008 first search found value: no second search required: 0.098 second search found value: no With shuffle (caching effects): value generation required: 1.454 first search required: 0.009 first search found value: no second search required: 0.044 second search found value: no Many thanks, dusha. P.S. I return the iterator and write out the result (found or not), because I would like to prevent compiler optimization, that it thinks the loop is not required at all. The searched value is obviously not in the vector.

    Read the article

  • Nested parsers in happy / infinite loop?

    - by McManiaC
    I'm trying to write a parser for a simple markup language with happy. Currently, I'm having some issues with infinit loops and nested elements. My markup language basicly consists of two elements, one for "normal" text and one for bold/emphasized text. data Markup = MarkupText String | MarkupEmph [Markup] For example, a text like Foo *bar* should get parsed as [MarkupText "Foo ", MarkupEmph [MarkupText "bar"]]. Lexing of that example works fine, but the parsing it results in an infinite loop - and I can't see why. This is my current approach: -- The main parser: Parsing a list of "Markup" Markups :: { [Markup] } : Markups Markup { $1 ++ [$2] } | Markup { [$1] } -- One single markup element Markup :: { Markup } : '*' Markups1 '*' { MarkupEmph $2 } | Markup1 { $1 } -- The nested list inside *..* Markups1 :: { [Markup] } : Markups1 Markup1 { $1 ++ [$2] } | Markup1 { [$1] } -- Markup which is always available: Markup1 :: { Markup } : String { MarkupText $1 } What's wrong with that approach? How could the be resolved? Update: Sorry. Lexing wasn't working as expected. The infinit loop was inside the lexer. Sorry. :) Update 2: On request, I'm using this as lexer: lexer :: String -> [Token] lexer [] = [] lexer str@(c:cs) | c == '*' = TokenSymbol "*" : lexer cs -- ...more rules... | otherwise = TokenString val : lexer rest where (val, rest) = span isValidChar str isValidChar = (/= '*') The infinit recursion occured because I had lexer str instead of lexer cs in that first rule for '*'. Didn't see it because my actual code was a bit more complex. :)

    Read the article

  • Django GenericRelation doesn't save related object's id - is this a bug or am I doing it wrong?

    - by pinkeen
    I have a model with a generic relation (call it A), when creating an instance of this object I pass an instance of another model (call it B) as the initializer of the content_object field (via kwargs of the constructor). If I don't save B before creating A then when saving A the content_object_id is saved to the db as NULL. If I save B before passing it to the constructor of A then everything's allright. It's not logical. I assumed that the ID of the related object (B) is fetched when doing A.save() and it should throw some kind of an exception if B isn't saved yet but it just fails silently. I don't like the current solution (saving B beforhand) because we don't know yet if I will be always willing to keep the object, not just scrap it, and there are performance considerations - what if I will add some another data and save it once more shortly after. class BaseNodeData(models.Model): ... extnodedata_content_type = models.ForeignKey(ContentType, null=True) extnodedata_object_id = models.PositiveIntegerField(null=True) extnodedata = generic.GenericForeignKey(ct_field='extnodedata_content_type', fk_field='extnodedata_object_id') class MarkupNodeData(models.Model): raw_content = models.TextField() Suppose we do: markup = MarkupNodeData(raw_content='...') base = BaseNodeData(..., extnodedata=markup) markup.save() base.save() # both records are inserted to the DB but base is stored with extnodedata_object_id=NULL markup = MarkupNodeData(raw_content='...') base = BaseNodeData(..., extnodedata=markup) base.save() markup.save() # no exception is thrown and everything is the same as above markup = MarkupNodeData(raw_content='...') markup.save() base = BaseNodeData(..., extnodedata=markup) base.save() # this works as expected Of course I can do it this way, but it doesn't change anything: base = BaseNodeData(...) base.extnodedata = markup My question is - is this a bug in django which I should report or maybe I'm doing something wrong. Docs on GenericRelations aren't exactly verbose.

    Read the article

  • Counting combinations in c or in python

    - by Dennis
    Hello I looked a bit on this topic here but I found nothing that could help me. I need a program in Python or in C that will give me all possible combinations of a and b that will meet the requirement n=2*a+b, for n from 0 to 10. a, b and n are integers. For example if n=0 both a and b must be 0. For n=1 a must be zero and b must be 1, for n=2 a can be 1 and b=0, or a=0 and b=2, etc. I'm not that good with programming. I made this: #include <stdio.h> int main(void){ int a,b,n; for(n = 0; n <= 10; n++){ for(a = 0; a <= 10; a++){ for(b = 0; b <= 10; b++) if(n == 2*a + b) printf("(%d, %d), ", (a,b)); } printf("\n"); } } But it keeps getting strange results like this: (0, -1079628000), (1, -1079628000), (2, -1079628000), (0, -1079628000), (3, -1079628000), (1, -1079628000), (4, -1079628000), (2, -1079628000), (0, -1079628000), (5, -1079628000), (3, -1079628000), (1, -1079628000), (6, -1079628000), (4, -1079628000), (2, -1079628000), (0, -1079628000), (7, -1079628000), (5, -1079628000), (3, -1079628000), (1, -1079628000), (8, -1079628000), (6, -1079628000), (4, -1079628000), (2, -1079628000), (0, -1079628000), (9, -1079628000), (7, -1079628000), (5, -1079628000), (3, -1079628000), (1, -1079628000), (10, -1079628000), (8, -1079628000), (6, -1079628000), (4, -1079628000), (2, -1079628000), (0, -1079628000), ideone Any idea what is wrong? Also if I could do this for Python it would be even cooler. :D

    Read the article

< Previous Page | 21 22 23 24 25 26 27  | Next Page >