Daily Archives

Articles indexed Wednesday June 16 2010

Page 2/119 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • With Rails 3 routes, how do you only allow a requests from 127.0.0.1?

    - by micah
    I'm writing an app where several of the routes should only be accessible from localhost. It looks like this is possible with the new routing system. http://www.railsdispatch.com/posts/rails-3-makes-life-better This has examples of restricting routes based on IP address, and setting up an IP address blacklist for your routes, but I'm interested in a whitelist with just one IP address. It would be cool if something like this worked: get "/posts" => "posts#show", :constraints => {:ip => '127.0.0.1'} But it didn't. Am I just missing the right syntax?

    Read the article

  • Detecting if MSBuild/.net 4 is installed from C# code running on 3.5?

    - by Michael Stum
    I have an application that is running on .net 3.5 SP1 and that is supposed to check if .net 4 is installed. Actually, I'm more interested if MSBuild v4 is installed, which would boil down to a simple File.Exists(@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"); However, apart from the fragility of the 4.0.30319 Version (and the Windir, but that's easy to solve), I wonder if there is a more appropriate way, like an API?

    Read the article

  • sql-server performance optimization by removing print statements

    - by AG
    We're going through a round of sql-server stored procedure optimizations. The one recommendation we've found that clearly applies for us is 'SET NOCOUNT ON' at the top of each procedure. (Yes, I've seen the posts that point out issues with this depending on what client objects you run the stored procedures from but these are not issues for us.) So now I'm just trying to add in a bit of common sense. If the benefit of SET NOCOUNT ON is simply to reduce network traffic by some small amount every time, wouldn't it also make sense to turn off all the PRINT statements we have in the stored procedures that we only use for debugging? I can't see how it can hurt performance. OTOH, it's a bit of a hassle to implement due to the fact that some of the print statements are the only thing within else clauses, so you can't just always comment out the one line and be done. The change carries some amount of risk so I don't want to do it if it isn't going to actually help. But I don't see eliminating print statements mentioned anywhere in articles on optimization. Is that because it is so obvious no one bothers to mention it?

    Read the article

  • how to add a port to mysql server

    - by Shvilam
    I wont to add to mysql other tcp port that he will be lessen to and i will be able to connect to that port from my application i have duplicate my appliction and i runing them both from the same machine they both connected to the mysql server that are running on the same machine the problem is that the default port 3306 all ready taken thanks

    Read the article

  • How do you get XML::Pastor to set xsi:type for programmatically generated elements?

    - by Derrick
    I'm learning how to use Perl as an automation test framework tool for a Java web service and running into trouble generating xml requests from the Pastor generated modules. The problem is that when including a type that extends from the required type for an element, the xsi:type is not included in the generated xml string. Say, for example, I want to generate the following xml request from the modules that XML::Pastor generated from my xsd: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <PromptAnswersRequest xmlns="http://mycompany.com/api"> <Uri>/some/url</Uri> <User ref="1"/> <PromptAnswers> <PromptAnswer xsi:type="textPromptAnswer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Prompt ref="2"/> <Children> <PromptAnswer xsi:type="choicePromptAnswer"> <Prompt ref="1"/> <Choice ref="2"/> </PromptAnswer> </Children> <Value>totally</Value> </PromptAnswer> </PromptAnswers> </PromptAnswersRequest> What I'm getting currently is this: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <PromptAnswersRequest xmlns="http://mycompany.com/api"> <Uri>/some/url</Uri> <User ref="1"/> <PromptAnswers> <PromptAnswer> <Prompt ref="2"/> <Children> <PromptAnswer> <Prompt ref="1"/> <Choice ref="2"/> </PromptAnswer> </Children> <Value>totally</Value> </PromptAnswer> </PromptAnswers> </PromptAnswersRequest> Here are some relavent snippets from the xsd: <xs:complexType name="request"> <xs:sequence> <xs:element name="Uri" type="xs:anyURI"/> </xs:sequence> </xs:complexType> <xs:complexType name="promptAnswersRequest"> <xs:complexContent> <xs:extension base="api:request"> <xs:sequence> <xs:element name="User" type="api:ref"/> <xs:element name="PromptAnswers" type="api:promptAnswerList"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="promptAnswerList"> <xs:sequence> <xs:element name="PromptAnswer" type="api:promptAnswer" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="promptAnswer" abstract="true"> <xs:sequence> <xs:element name="Prompt" type="api:ref"/> <xs:element name="Children" type="api:promptAnswerList" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="textPromptAnswer"> <xs:complexContent> <xs:extension base="promptAnswer"> <xs:sequence> <xs:element name="Value" type="api:nonEmptyString" minOccurs="0"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> And here are relavent parts of the script: my $promptAnswerList = new My::API::Type::promptAnswerList; my @promptAnswers; my $promptAnswerList2 = new My::API::Type::promptAnswerList; my @textPromptAnswerChildren; my $textPromptAnswer = new My::API::Type::textPromptAnswer; my $textPromptAnswerRef = new My::API::Type::ref; $textPromptAnswerRef->ref('2'); $textPromptAnswer->Prompt($textPromptAnswerRef); my $choicePromptAnswer = new My::API::Type::choicePromptAnswer; my $choicePromptAnswerPromptRef = new My::API::Type::ref; my $choicePromptAnswerChoiceRef = new My::API::Type::ref; $choicePromptAnswerPromptRef->ref('1'); $choicePromptAnswerChoiceRef->ref('2'); $choicePromptAnswer->Prompt($choicePromptAnswerPromptRef); $choicePromptAnswer->Choice($choicePromptAnswerChoiceRef); push(@textPromptAnswerChildren, $choicePromptAnswer); $promptAnswerList2->PromptAnswer(@textPromptAnswerChildren); $textPromptAnswer->Children($promptAnswerList2); $textPromptAnswer->Value('totally'); push(@promptAnswers, $pulseTextPromptAnswer); push(@promptAnswers, $textPromptAnswer); I haven't seen this addressed anywhere in the documentation for the XML::Pastor modules, so if anyone can point me at a good reference for its use it would be greatly appreciated. Also, I'm only using XML::Pastor because I don't know of any other modules that can do this, so if any of you know of something either easier to use, or more well maintained, please let me know about that too!

    Read the article

  • Websites that archive cross-browser, cross-platform css/js bugs?

    - by meder
    I'm about to develop my own browser inconsistency/bug compendium site but I'm wondering if I really need to - can we get a wiki of sites that do this already? I'm aware of a lot of them but I hope I'm not missing out on some major ones. I wanted mine to be more intuitive and social-like for most people, powered by tags and screenshots and test-case pages.

    Read the article

  • efficient algorithm for drawing circle arcs?

    - by banister
    I am using the mid-point circle algorithm (bresenham circle) to efficiently draw whole circles. Is there something similar to draw circle arcs? I would like to specify a start angle and end angle and have only that portion of the circle drawn. Thanks in advance! EDIT: I would like to draw filled circle arcs too, i.e pie-slices. :)

    Read the article

  • Trying to manually recreate a simple generate/scaffolding script

    - by montooner
    I'm trying to understand Rails from the ground up. I want to learn how to manually create basic show-all/show-single/CRUD functionality in the framework. I currently am working on the display-all functionality, but am stopped by an error when I try to request all items in the Products db Here are the steps I've taken so far: script/generate controller Products script/generate model Products rake db:migrate modified products_controller.rb to add: def index() { @products = Product.all} (error: uninitialized constant ProductsController::Product) ideally, dump all orders in the view What's the fix?

    Read the article

  • Naming Optional Parameters in VSB

    - by SteveNeedsSheetNames
    In Visual Basic, I have Functions with a lot of Optional arguments. I would like to be able to pass just a few of these Optional arguments to a Function without having to use numerous commas and spaces to get to the ones I want. Somewhere I saw a way to name params such as OptVar:=val, but that does not seem to work. Just wondering if there is a way to do this. This would help readability. Thanks in advance for the replies.

    Read the article

  • How do I model teams and gameplay in this scorekeeping application?

    - by Eric Hill
    I'm writing a scorekeeping application for card game that has a few possibly-interesting constraints. The application accepts user registrations for players, then lets them check-in to a particular game (modeled as Event). After the final player registers, the app should generate teams, singles or doubles, depending on the preference of the person running the game and some validations (can't do doubles if there's an odd number checked in). There are @event.teams.count rounds in the game. To sum up: An event consists of `@event.teams.count` rounds; Teams can have 1 or more players Events have n or n/2 teams (depending on whether it's singles or doubles) Users will be members of different teams at different events Currently I have a rat's nest of associations: class User < ActiveRecord::Base has_many :teams, :through => :players has_many :events, :through => :teams class Event < ActiveRecord::Base has_many :rounds has_many :teams has_many :players, :through => :teams class Player < ActiveRecord::Base belongs_to :user belongs_to :team end class Team < ActiveRecord::Base has_many :players belongs_to :event end class Round < ActiveRecord::Base belongs_to :event belongs_to :user end The sticky part is team generation. I have basically a "start game" button that should freeze the registrations and pair up teams either singly or doubly, and render to Round#new so that the first (and subsequent) matches can be scored. Currently I'm implementing this as a check on Round#new that calls Event#generate_teams and displays the view: # Event#generate_teams def generate_teams # User has_many :events, :through => :registrations # self.doubles is a boolean denoting 2 players per team registrations.in_groups_of(self.doubles ? 2 : 1, nil).each do |side| self.teams << Player.create(self,side) end end Which doesn't work. Should there maybe be a Game model that ties everything together rather than (my current method) defining the game as an abstraction via the relationships between Events, Users, and Rounds (and Teams and Players and etc.)? My head is swimming.

    Read the article

  • LibraryContainer in a ScatterViewItem: resizing and background rectangle...

    - by Rob Fleming
    Simple one: Want to add a LibraryContainer to a Surface ScatterView. Know I have to add the container inside a ScatterViewItem to get the rotate/move features.. but the SVI adds a rectangle box around the control, and it does not size correctly. Think I'm missing something simple but can't figure it... My current XAML is as follows: Background="{StaticResource WindowBackground}" AllowDrop="True" . . . Any thoughts are appreciated... I've been looking at the how-to samples but the library controls that are shown are static item. (ie they are not movable)... Rob

    Read the article

  • HMVC or PAC - how to handle shared abstractions/models?

    - by fig-gnuton
    In HMVC/PAC, what's the recommended way to code if two or more triads/agents share a common model/abstraction? Do you instantiate a new instance of that model wherever needed, and propogate a change in one to all the other instances via the controllers? Or do instantiate one model at some common upper level, and inject that instance wherever needed? (Or neither if I'm missing something fundamental about these patterns?)

    Read the article

  • Parsing EXIF's "ExposureTime" using PHP

    - by MarkL
    Re, One photo with exposure being 1/640 has the EXIF field of "ExposureTime" eq. "15625/10000000". I am not sure why some photos display this value in a readable format (e.g., "1/100"), but I need to convert this "15625" back to "1/640". How? :) Thanks.

    Read the article

  • Creating standalone, console (shell) for domain-specific operations

    - by mr.b
    Say that I have a system service, and I want to offer a low-level maintenance access to it. For that purpose, I'd like to create a standalone, console application that somehow connects to server process and lets user type in commands, allow it to use auto-completion and auto-suggestion on single/double TAB press (just like linux bash shell, mysql cli, cmd.exe, and countless others), allow command line editing capabilities (history, cursor keys to move around text..), etc. Now, it's not that much of a problem to create something like that by rolling my own from scratch, handling user input, scanning pressed keys, and doing correct actions. But, why reinvent the wheel? Is there some library/framework that helps with this kind of problems, just like readline library that offers improved command-line editing capabilities under linux? Of course, this new "shell" would respond only to valid, domain-specific commands, and would suggest valid arguments, options, switches... Any ideas? Thanks!

    Read the article

  • .rdlc reporting bound to Object Data Source in Three layer Application

    - by Saeedouv
    Hi, i have the following situation, i have a Reporting layer(stand alone) in asp.net application(NOT website, this means NO App_Code folder exists), and i want just to create Object Data Source to take an Object in a separate layer(lets say from Data Access Layer), and then to use that Object Data Source to create a report, i have spent my whole day working around that, tons of work around's and articles on the web, but does not mention what i really want to do, any answer is appriciated... just to make things more clear here, assume the following: i have a solution with the follwoing layers, UI Reporting(has NO Employees object) just a reference Business Logic Data Access Layer(Employees--GetEmployees(), all i need is as mentioned above, i want to create Object Data Source from Reporting layer, to take Employee object from DAL, and then use it's GetEmployees method to be added to report, i think its more clear now, since also Reporting layer has NO App_Code folder.

    Read the article

  • DeSerialization doesn't work though i Implement GetObjectData method and Constructor

    - by Punit Singhi
    Hi, I have a static generic dictionary in a class. As static memeber cannot serialized so i have implented ISerializable interface and method GetObjectData to serialize. I have a constructor which will also accept SerializationInfo and StreamingContext to deserliaze the dictionay. Now when i try to serialize and deserialize , it always return 1(thoug i added 2 entries). please find the pseduo code- [Serializable] public class MyClass : ISerializable { internal static Dictionary<long, string> dict = new Dictionary<long,string>(); public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("static.dic", MyClass1.dict, typeof(Dictionary<long, string>)); } public MyClass(SerializationInfo info, StreamingContext context) { MyClass.dict= (Dictionary<long, string>)info.GetValue("static.dic", typeof(Dictionary<long, string>)); } public void Add() { dict.Add(21, "11"); } public MyClass() { dict.Add(21, "11"); } } public class MyClass { MyClass myClass = new MyClass(); public static void Main() { myClass.Add(); FileStream fileStream = new FileStream("test.binary", FileMode.Create); IFormatter bf = new BinaryFormatter(); bf.Serialize(fileStream, myClass); fileStream.Dispose(); fileStream.Close(); fileStream = new FileStream("test.binary", FileMode.Open); bf = new BinaryFormatter(); myClass = (MyClass1)bf.Deserialize(fileStream); } }

    Read the article

  • [java] how to parse XML document?

    - by user32167
    I have xml document in variable (not in file). How can i get data storaged in that? I don't have any additional file with that, i have it 'inside' my sourcecode. When i use DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(XML); (XML is my xml variable), i get an error java.io.FileNotFoundException: C:\netbeans\app-s7013\<network ip_addr="10.0.0.0\8" save_ip="true"> File not found.

    Read the article

  • Bad temperature sensors on Foxconn motherboard?

    - by Gawain
    I have a system with a Foxconn V400 series motherboard and AMD Athlon 3000+ processor. Ever since I got it a few years ago the fans (particularly the CPU fan) have been really loud. So recently I installed SpeedFan to see why they were running so fast. SpeedFan reported the CPU temperature to be 32C, and one motherboard sensor at about 26C. But the other two motherboard sensors were reporting 78C and 64C respectively. Naturally the fans were both maxed out because of this, with the CPU fan at 5800rpm and the case fan at 2400rpm. I opened the case and everything inside was literally cool to the touch, with the exception of the CPU heatsink which was slightly warm, but nowhere near 78C. It seems like the temperature sensors are either defective or being read incorrectly. Is there some way I can decrease my fan noise without risking damage to my processor? Some way to ignore those two temp sensors? Any help would be greatly appreciated.

    Read the article

  • document.onclick settimeout function javascript help

    - by Jamex
    Hi, I have a document.onclick function that I would like to have a delay. I can't seem to get the syntax right. my original code is <script type="text/javascript"> document.onclick=check; function check(e){do something} I tried the below, but that code is incorrect, the function did not execute and nothing happened. <script type="text/javascript"> document.onclick=setTimeout("check", 1000); function check(e){do something} I tried the next set, the function got executed, but no delay. <script type="text/javascript"> setTimeout(document.onclick=check, 1000); function check(e){do something} what is the correct syntax for this code. TIA Edit: The solutions were all good, my problem was that I use the function check to obtain the id of the element being clicked on. But after the delay, there is no "memory" of what was being clicked on, so the rest of the function does not get executed. Jimr wrote the short code to preserve clicked event. The code that is working is // Delay execution of event handler function "f" by "time" ms. document.onclick = makeDelayedHandler(check, 250); function makeDelayedHandler( f, time) { return function( e ) {setTimeout(function() {f( e );}, time ); }; } function check(e){ var click = (e && e.target) || (event && event.srcElement); . . . Thank you all.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >