Daily Archives

Articles indexed Thursday March 25 2010

Page 14/127 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Scanf with Signals

    - by jreid42
    I have a signal that blocks SIGINT and basically says "Sorry, you can't quit.\n" The issue is this can occur during a scanf. When this occurs during a scanf, scanf takes in the printf as input. How can I do a printf that will cause scanf to basically hit the enter key automatically. I don't care that I am getting bad input. I just want to programatically finish that scanf with a printf or something else. Process: scanf("get stuff") - User is able to enter stuff in. - SIGINT occurs and goes to my handler. - Handler says "Blah blah blah" to stdout. - Scanf has taken this blah blah blah and is waiting for more input. How do I make it so that when I return scanf is finished (don't care what it has gathered I just want it to continue without user help).

    Read the article

  • How do I setup ASP.NET MVC 2 with MySQL?

    - by NovaJoe
    Okay, so I'm cheating and not actually a question, but instead making a flat-out post. I know that goes against the grain of Stack Overflow, but this is too valuable not to share. I'm assuming that you have Visual Studio Professional 2008 and access to an instance of MySQL server. This MAY work with VS2008 Web edition, but not at all sure. If you haven't, install MySQL Connector for .NET (6.2.2.0 at the time of this write-up) Optional: install MySQL GUI Tools If you haven't, install MVC 2 RTM, or better yet, use Microsoft's Web Platform Installer. Create an empty MySQL database. If you don't want to access your application with the MySQL root user account (insecure), create a user account and assign the appropriate privileges (outside the scope of this write-up). Create a new MVC 2 application in Visual Studio In the MVC 2 app, reference MySql.Web.dll. It will either be in your GAC, or in the folder that the MySQL Connector installer put it. Modify the connection strings portion of your web.config: <connectionStrings> <remove name="LocalMySqlServer"/> <add name="MySqlMembershipConnection" connectionString="Data Source=[MySql server host name];user id=[user];password=[password];database=[database name];" providerName="MySql.Data.MySqlClient"/> </connectionStrings> Modify the membership portion of your web.config: <membership defaultProvider="MySqlMembershipProvider"> <providers> <clear/> <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="MySqlMembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" autogenerateschema="true"/> </providers> </membership> Modify the role manager portion of your web.config: <roleManager enabled="true" defaultProvider="MySqlRoleProvider"> <providers> <clear /> <add connectionStringName="MySqlMembershipConnection" applicationName="/" name="MySqlRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="true"/> </providers> </roleManager> Modify the profile portion of your web.config: <profile> <providers> <clear/> <add type="MySql.Web.Security.MySQLProfileProvider, MySql.Web, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" name="MySqlProfileProvider" applicationName="/" connectionStringName="MySqlMembershipConnection" autogenerateschema="true"/> </providers> </profile> At this point, you ought to be able to run the app and have the default ASP.NET MVC 2 home page come up in your browser. However, it may be a better idea to first run the ASP.NET Web configuration Tool (in Visual Studio top menus: Project - ASP.NET Configuration). Once the tool launches, check out each of the tabs; no errors = all good. The configuration tool Nathan Bridgewater's blog was essential to getting this working. Kudos, Nathan. Look for the "Configuration Tool" heading half way down the page. The public key token on the MySql.web.dll that I've posted here ought not change any time soon. But in case you suspect a bad token string from copying and pasting or whatever, just use the Visual Studio command line to run: "sn -T [Path\to\your.dll]" in order to get the correct public key token. There you have it, ASP.NET MVC 2 running over MySQL. Cheers!

    Read the article

  • Using mod_rewrite for a RESTful api

    - by razass
    Say the user is making a request to the following url: "http://api.example.com/houses/123/abc" That request needs to map to "/webroot/index.php" and 'houses', '123', 'abc' need to be able to be parsed out of the URL in that index.php. It also can't alter the http headers or body. There can be any number of variables after the domain ie) "http://api.example.com/houses/1234/abc/zxy/987" I think I already have all requests being sent to webroot using: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond $0 !^webroot/ RewriteRule .* webroot/$0 [L] </IfModule> Which appears to be working but I am not sure if it is correct. But now I am at a loss as to how to take the next step as mentioned above. Thanks in advance!

    Read the article

  • Subscribe to YouTube channel in iTunes

    - by ejunker
    What is the best way to subscribe to a YouTube channel and have it show up in iTunes as a podcast? I want iTunes to automatically download the videos in MP4 format or download them in FLV and convert them to MP4 in iPod format. I have used these services in the past but they don't seem to be working anymore: RSSHandler Youtube Podcaster

    Read the article

  • Clustering for Mere Mortals (Pt 3)

    - by Geoff N. Hiten
    The Controller Now we get to the meat of the matter.  You want a virtual cluster, the first thing you have to do is create your own portable domain.  Start with a plain vanilla install of Windows 2003 R2 Standard on a semi-default VM. (1 GB RAM, 2 cores, 2 NICs, 128GB dynamically expanding VHD file).  I chose this because it had the smallest disk and memory footprint of any current supported Microsoft Server product.  I created the VM with a single dynamically expanding VHD, one fixed 16 GB VHD, and two NICs.  One NIC is connected to the outside world and the other one is part of an internal-only network.  The first NIC is set up as a DHCP client.  We will get to the other one later. I actually tried this with Windows 2008 R2, but it failed miserably.  Not sure whether it was 2008 R2 or the fact I tried to use cloned VMs in the cluster.  Clustering is one place where NewSID would really come in handy.  Too bad Microsoft bought and buried it. Load and Patch the OS (hence the need for the outside connection).This is a good time to go get dinner.  Maybe a movie too.  There are close to a hundred patches that need to be downloaded and applied.  Avoiding that mess was why I put so much time into trying to get the 2008 R2 version working.  Maybe next time.  Don’t forget to add the extensions for VMLite (or whatever virtualization product you prefer). Set a fixed IP address on the internal-only NIC.  Do not give it a gateway.  Put the same IP address for the NIC and for the DNS Server.  This IP should be in a range that is never available on your public network.  You will need all the addresses in the range available.  See the previous post for the exact settings I used. I chose 10.97.230.1 as the server.  The rest of the 10.97.230 range is what I will use later.  For the curious, those numbers are based on elements of my home address.  Not truly random, but good enough for this project. Do not bridge the network connections.  I never allowed the cluster nodes direct access to any public network. Format the fixed VHD and leave it alone for now. Promote the VM to a Domain Controller.  If you have never done this, don’t worry.  The only meaningful decision is what to call the new domain.  I prefer a bogus name that does not correspond to a real Top-Level Domain (TLD).  .com, .biz., .net, .org  are all TLDs that we know and love.  I chose .test as the TLD since it is descriptive AND it does not exist in the real world.  The domain is called MicroAD.  This gives me MicroAD.Test as my domain. During the promotion process, you will be prompted to install DNS as part of the Domain creation process.  You want to accept this option.  The installer will automatically assign this DNS server as the authoritative owner of the MicroAD.test DNS domain (not to be confused with the MicroAD.test Active Directory domain.) For the rest of the DCPROMO process, just accept the defaults. Now let’s make our IP address management easy.  Add the DHCP Role to the server.  Add the server (10.97.230.1 in this case) as the default gateway to assign to DHCP clients.  Here is where you have to be VERY careful and bind it ONLY to the Internal NIC.  Trust me, your network admin will NOT like an extra DHCP server “helping” out on her network.  Go ahead and create a range of 10-20 IP Addresses in your scope.  You might find other uses for a pocket domain controller <cough> Mirroring </cough> than just for building a cluster.  And Clustering in SQL 2008 and Windows 2008 R2 fully supports DHCP addresses. Now we have three of the five key roles ready.  Two more to go. Next comes file sharing.  Since your cluster node VMs will not have access to any outside, you have to have some way to get files into these VMs.  I simply go to the root of C: and create a “Shared” folder.  I then share it out and grant full control to “Everyone” to both the share and to the underlying NTFS folder.   This will be immensely useful for Service Packs, demo databases, and any other software that isn’t packaged as an ISO that we can mount to the VM. Finally we need to create a block-level multi-connect storage device.  The kind folks at Starwinds Software (http://www.starwindsoftware.com/) graciously gave me a non-expiring demo license for expressly this purpose.  Their iSCSI SAN software lets you create an iSCSI target from nearly any storage medium.  Refreshingly, their product does exactly what they say it does.  Thanks. Remember that 16 GB VHD file?  That is where we are going to carve into our LUNs.  I created an iSCSI folder off the root, just so I can keep everything organized.  I then carved 5 ea. 2 GB iSCSI targets from that folder.  I chose a fixed VHD for performance.  I tried this earlier with a dynamically expanding VHD, but too many layers of abstraction and sparseness combined to make it unusable even for a demo.  Stick with a fixed VHD so there is a one-to-one mapping between abstract and physical storage.  If you read the previous post, you know what I named these iSCSI LUNs and why.  Yes, I do have some left over space.  Always leave yourself room for future growth or options. This gets us up to where we can actually build the nodes and install SQL.  As with most clusters, the real work happens long before the individual nodes get installed and configured.  At least it does if you want the cluster to be a true high-availability platform.

    Read the article

  • rails when to use self.

    - by fenec
    i am developing a rails application and would like to understand when do we use self.for . here is the code of a method that i would like to fully understand.if it is possible i would like to have an alternative to this code so it would make things more clear. enter code here def self.for(facebook_id) User.create_by_facebook_id(facebook_id) end

    Read the article

  • Is it a Good Practice to Write HTML Using a StringBuilder in my ASP.NET Codebehind?

    - by d3020
    I'm interested to hear from other developers their opinion on an approach that I typically take. I have a web application, asp.net 2.0, c#. What I usually do to write out drop downs, tables, input controls, etc. is in the code behind use StringBuilder and write out something like sb.Append(" I don't find myself using to many .net controls as I typically write out the html in the code behind. When I want to use jQuery or call JavaScript I just put that function call in my sb.Append tag like sb.Append("td...onblur='fnCallJS()'. I've gotten pretty comfortable with this approach. For data access I use EntitySpaces. I'm just kind of curious if this sort of approach is horribly wrong, ok depending on the context, good, time to learn 3.0, etc. I'm interested in learning and was just looking for some input.

    Read the article

  • use Services in MVVM

    - by netmajor
    I want to use Services(WCF/RIA /Web) to take data from Entity Data Model class (maybe NHibernate class) and prepared it special for View layer binding. I have few Silverlight page, so should I create for each page separate service class ? Or create one interface and all method will implement it in one service class? Do You have some advice helped with my with services ?

    Read the article

  • How to speed up Cygwin?

    - by tester
    I have been running drush scripts (for drupal) with cygwin on my relatively fast windows machine, but I still have to wait about a minute for any drush command (specifically drush cache clear to execute). I'm quite sure it has something to do with the speed of cygwin since my fellow developers (who are running linux) can run these scripts in about 5 seconds. Is there a way to make cygwin use more memory and/or cpu per terminal?

    Read the article

  • Why does UIImageView "darken"/saturate PNG images, and can I stop it?

    - by Ben
    I have a PNG file in a UIImageView, and next to that I have an EAGLView which displays the continuation of that same image (long story) as a texture, carved from the same original PNG. The point is, that these images, which should match up flawlessly, actually have somewhat differing color saturation. Normally I'd blame my handling of the PNG texture load in GL, but when I hold Preview (with the PNG) up to the iPhone simulator, it's GL that's spot on, and the UIImageView that's wrong! It's taken the image and made it ever-so-slightly more saturated. The image view is opaque with 100% alpha. I verified this on a clean UIImageView with another PNG file when put next to Preview. Anyone know what's up?

    Read the article

  • Can't get SFTP to work in PHP

    - by Chris Kloberdanz
    I am writing a simple SFTP client in PHP because we have the need to programatically retrieve files via n remote servers. I am using the PECL SSH2 extension. I have run up against a road block, though. The documentation on php.net suggests that you can do this: $stream = fopen("ssh2.sftp://$sftp/path/to/file", 'r'); However, I have an ls method that attempts to something similar public function ls($dir) { $rd = "ssh2.sftp://{$this->sftp}/$dir"; $handle = opendir($rd); if (!is_resource($handle)) { throw new SFTPException("Could not open directory."); } while (false !== ($file = readdir($handle))) { if (substr($file, 0, 1) != '.'){ print $file . "\n"; } } closedir($handle); } I get the following error: PHP Warning: opendir(): Unable to open ssh2.sftp://Resource id #5/outgoing on remote host This makes perfect sense because that's what happens when you cast a resource to string. Is the documentation wrong? I tried replacing the resource with host, username, and host and that didn't work either. I know the path is correct because I can run SFTP from the command line and it works fine. Has anyone else tried to use the SSH2 extenstion with SFTP? Am I missing something obvious here? UPDATE: I setup sftp on another machine in-house and it works just fine. So, there must be something about the server I am trying to connect to that isn't working.

    Read the article

  • ASP.net - First build fails with 'Unknown server tag'

    - by Sophia
    I have multiple custom controls used on a ASPX (and C#) page registered from within the page rather than in Web.Config. On the first build (or rebuild), build fails with error messages for wherever I've used the custom controls. Subsequent builds are successful. The error message: Unknown server tag 'prefix:ExampleControl'. What might cause this, and how can I fix it? Register syntax: <%@ Register Src="ControlsFolder/ExampleControl.ascx" TagName="ExampleControl" TagPrefix="prefix" %> <!-- etc --> Usage syntax: <prefix:ExampleControl runat="server" ID="ExampleControl1" /> <!-- etc -->

    Read the article

  • How Marketing Consulting Firms Can Generate SEO Bonuses

    Companies allot budgets for online Marketing Consulting Firms to expand the client base therefore resulting into more revenue. Most SEO professionals offer packages that are designed to improve website visibility for both visitors and search engines. Basically, the optimization of the content takes place with the use of keywords in the title and body tags.

    Read the article

  • Catch Multiple Custom Exceptions? - C++

    - by Alex
    Hi all, I'm a student in my first C++ programming class, and I'm working on a project where we have to create multiple custom exception classes, and then in one of our event handlers, use a try/catch block to handle them appropriately. My question is: How do I catch my multiple custom exceptions in my try/catch block? GetMessage() is a custom method in my exception classes that returns the exception explanation as a std::string. Below I've included all the relevant code from my project. Thanks for your help! try/catch block // This is in one of my event handlers, newEnd is a wxTextCtrl try { first.ValidateData(); newEndT = first.ComputeEndTime(); *newEnd << newEndT; } catch (// don't know what do to here) { wxMessageBox(_(e.GetMessage()), _("Something Went Wrong!"), wxOK | wxICON_INFORMATION, this);; } ValidateData() Method void Time::ValidateData() { int startHours, startMins, endHours, endMins; startHours = startTime / MINUTES_TO_HOURS; startMins = startTime % MINUTES_TO_HOURS; endHours = endTime / MINUTES_TO_HOURS; endMins = endTime % MINUTES_TO_HOURS; if (!(startHours <= HOURS_MAX && startHours >= HOURS_MIN)) throw new HourOutOfRangeException("Beginning Time Hour Out of Range!"); if (!(endHours <= HOURS_MAX && endHours >= HOURS_MIN)) throw new HourOutOfRangeException("Ending Time Hour Out of Range!"); if (!(startMins <= MINUTE_MAX && startMins >= MINUTE_MIN)) throw new MinuteOutOfRangeException("Starting Time Minute Out of Range!"); if (!(endMins <= MINUTE_MAX && endMins >= MINUTE_MIN)) throw new MinuteOutOfRangeException("Ending Time Minute Out of Range!"); if(!(timeDifference <= P_MAX && timeDifference >= P_MIN)) throw new PercentageOutOfRangeException("Percentage Change Out of Range!"); if (!(startTime < endTime)) throw new StartEndException("Start Time Cannot Be Less Than End Time!"); } Just one of my custom exception classes, the others have the same structure as this one class HourOutOfRangeException { public: // param constructor // initializes message to passed paramater // preconditions - param will be a string // postconditions - message will be initialized // params a string // no return type HourOutOfRangeException(string pMessage) : message(pMessage) {} // GetMessage is getter for var message // params none // preconditions - none // postconditions - none // returns string string GetMessage() { return message; } // destructor ~HourOutOfRangeException() {} private: string message; };

    Read the article

  • How to force multiple Interfaces to include certain the same properties?

    - by Jed
    I am trying to figure out a way to force all of my Interfaces to include properties of the same name/type. For example: I have two Interfaces; IGetAlarms and IGetDiagnostics. Each of the Interfaces will contain properties that are specific to the Interface itself, however I want to force the two Interfaces (and all other Interfaces that may be added later) to include properties of the same name. So, the result may look something like the this: interface IGetAlarms { string GetAlarms(); DateTime LastRuntime { get; set; } } interface IGetDiagnostics { string GetDiagnostics(); DateTime LastRuntime { get; set; } } Notice that both Interfaces include a DateTime property named LastRuntime. I would like to know if there is some way I can force other Interfaces that will be added later to include the DateTime LastRuntime property. I have naively attempted to have all my Interfaces implement another Interface (IService) - which includes the LastRuntime property. However, that doesn't solve my problem as that simply forces the class to implement the property - not all the Interfaces. Thanks.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >