Search Results

Search found 1557 results on 63 pages for 'daniel gollas'.

Page 40/63 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • Should a Unit-test replicate functionality or Test output?

    - by Daniel Beardsley
    I've run into this dilemma several times. Should my unit-tests duplicate the functionality of the method they are testing to verify it's integrity? OR Should unit tests strive to test the method with numerous manually created instances of inputs and expected outputs? I'm mainly asking the question for situations where the method you are testing is reasonably simple and it's proper operation can be verified by glancing at the code for a minute. Simplified example (in ruby): def concat_strings(str1, str2) return str1 + " AND " + str2 end Simplified functionality-replicating test for the above method: def test_concat_strings 10.times do str1 = random_string_generator str2 = random_string_generator assert_equal (str1 + " AND " + str2), concat_strings(str1, str2) end end I understand that most times the method you are testing won't be simple enough to justify doing it this way. But my question remains; is this a valid methodology in some circumstances (why or why not)?

    Read the article

  • Smartfoxserver java extension

    - by Daniel
    Hello, I'v created a java extension that handles login requests using smartfoxserver for my game. The following is inside the internal event: View Here: http://mfpurl.net/index.php/view/8e43b130 But its complaining invalid login request?

    Read the article

  • How do I change a child's parent in NHibernate when cascade is delete-all-orphan?

    - by Daniel T.
    I have two entities in a bi-directional one-to-many relationship: public class Storage { public IList<Box> Boxes { get; set; } } public class Box { public Storage CurrentStorage { get; set; } } And the mapping: <class name="Storage"> <bag name="Boxes" cascade="all-delete-orphan" inverse="true"> <key column="Storage_Id" /> <one-to-many class="Box" /> </bag> </class> <class name="Box"> <many-to-one name="CurrentStorage" column="Storage_Id" /> </class> A Storage can have many Boxes, but a Box can only belong to one Storage. I have them mapped so that the one-to-many has a cascade of all-delete-orphan. My problem arises when I try to change a Box's Storage. Assuming I already ran this code: var storage1 = new Storage(); var storage2 = new Storage(); storage1.Boxes.Add(new Box()); Session.Create(storage1); Session.Create(storage2); The following code will give me an exception: // get the first and only box in the DB var existingBox = Database.GetBox().First(); // remove the box from storage1 existingBox.CurrentStorage.Boxes.Remove(existingBox); // add the box to storage2 after it's been removed from storage1 var storage2 = Database.GetStorage().Second(); storage2.Boxes.Add(existingBox); Session.Flush(); // commit changes to DB I get the following exception: NHibernate.ObjectDeletedException : deleted object would be re-saved by cascade (remove deleted object from associations) This exception occurs because I have the cascade set to all-delete-orphan. The first Storage detected that I removed the Box from its collection and marks it for deletion. However, when I added it to the second Storage (in the same session), it attempts to save the box again and the ObjectDeletedException is thrown. My question is, how do I get the Box to change its parent Storage without encountering this exception? I know one possible solution is to change the cascade to just all, but then I lose the ability to have NHibernate automatically delete a Box by simply removing it from a Storage and not re-associating it with another one. Or is this the only way to do it and I have to manually call Session.Delete on the box in order to remove it?

    Read the article

  • Apache RewriteRule: it is possible to 'detect' the first and second path segment?

    - by DaNieL
    Im really really a newbie in regexp and I can’t figure out how to do that. My goal is to have the RewriteRule to 'slice' the request URL path in 3 parts: example.com/foo #should return: index.php?a=foo&b=&c= example.com/foo/bar #should return: index.php?a=foo&b=bar&c= example.com/foo/bar/baz #should return: index.php?a=foo&b=bar&c=baz example.com/foo/bar/baz/bee #should return: index.php?a=foo&b=bar&c=baz/bee example.com/foo/bar/baz/bee/apple #should return: index.php?a=foo&b=bar&c=baz/bee/apple example.com/foo/bar/baz/bee/apple/and/whatever/else/no/limit/in/those/extra/parameters #should return: index.php?a=foo&b=bar&c=baz/bee/apple/and/whatever/else/no/limit/in/those/extra/parameters In short, the first segment in the URL path (foo) should be given to a, the second segment (bar) to b, and the rest of the string in c I wroted this one <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(([a-z0-9/]))?(([a-z0-9/]+))?(([a-z0-9]+))(.*)$ index.php?a=$1&b=$2&c=$3 [L,QSA] </IfModule> But obviously doesn’t work, and I don’t even know if what I want is possible. Any suggestion? EDIT: After playing with coach manager, I got this one working too: RewriteRule ^([^/]*)?/?([^/]*)?/?(.*)?$ index.php?a=$1&b=$2&c=$3 [L,QSA]

    Read the article

  • best way to add and delete text lines with jquery product configurator

    - by Daniel White
    I am creating a product configurator with Jquery. My users can add custom text lines to their product. So you could create say... 4 text lines with custom text. I need to know what the best way to add and delete these lines would be. Currently I have the following code for adding lines... //Add Text Button $('a#addText').live('click', function(event) { event.preventDefault(); //Scroll up the text editor $('.textOptions').slideUp(); $('#customText').val(''); //count how many items are in the ul textList var textItems = $('ul#textList li').size(); var nextNumber = textItems + 1; if(textItems <= 5) { //Change input to reflect current text being changed $('input#currentTextNumber').val(nextNumber); //Append a UL Item to the textList $('ul#textList').append('<li id="textItem'+nextNumber+'">Text Line. +$5.00 <a class="deleteTextItem" href="'+nextNumber+'">Delete</a></li>'); //Scroll down the text editor $('.textOptions').slideDown(); }else { alert('you can have a maximum of 6 textual inputs!'); } }); I'm probably not doing this the best way, but basically i have an empty UL list to start with. So when they click "Add Text Line" it finds out how many list elements are in the unordered list, adds a value of 1 to that and places a new list element with the id TextItem1 or TextItem2 or whatever number we're on. The problem i'm running into is that when you click delete item, it screws everything up because when you add an item again all the numbers aren't correct. I thought about writing some kind of logic that says all the numbers above the one you want deleted get 1 subtracted from their value and all the numbers below stay the same. But I think i'm just going about this the wrong way. Any suggestions on the easiest way to add and delete these text lines is appreciated.

    Read the article

  • Problems with ASP.NET, machine-level web.config, and the location element

    - by Daniel Schaffer
    I've got a server running Windows Web Server 2008 R2. The machine-level web.config has the following entries: <location path="Preview"> <appSettings> <add key="Environment" value="Preview" /> </appSettings> </location> <location path="Staging"> <appSettings> <add key="Environment" value="Staging" /> </appSettings> </location> <location path="Production"> <appSettings> <add key="Environment" value="Production" /> </appSettings> </location> I have a website that I'd set up in the direction D:\Sites\Preview\, so the full path would be D:\Sites\Preview\WebSite1. If I put a simple aspx file that just outputs the value of ConfigurationManager.AppSettings["Environment"], it displays the value Preview. I'm not clear on exactly how that works, but it does. I'd set this up several weeks ago, and just now tried to duplicate this - I put a second site in the D:\Sites\Preview\ directory, expecting that it would automatically pick up the appropriate appSettings entries, but for some reason it hasn't - the same aspx page doesn't show anything. Additionally, when I go into the IIS manager and open the Configuration Editor, there are no settings in there, whereas there are settings listed for the first site. Any ideas as to what I could be missing? Is the location element intended to work like this, or did I just find some magical fluke with my first site?

    Read the article

  • Rails. Putting update logic in your migrations

    - by Daniel Abrahamsson
    A couple of times I've been in the situation where I've wanted to refactor the design of some model and have ended up putting update logic in migrations. However, as far as I've understood, this is not good practice (especially since you are encouraged to use your schema file for deployment, and not your migrations). How do you deal with these kind of problems? To clearify what I mean, say I have a User model. Since I thought there would only be two kinds of users, namely a "normal" user and an administrator, I chose to use a simple boolean field telling whether the user was an adminstrator or not. However, after I while I figured I needed some third kind of user, perhaps a moderator or something similar. In this case I add a UserType model (and the corresponding migration), and a second migration for removing the "admin" flag from the user table. And here comes the problem. In the "add_user_type_to_users" migration I have to map the admin flag value to a user type. Additionally, in order to do this, the user types have to exist, meaning I can not use the seeds file, but rather create the user types in the migration (also considered bad practice). Here comes some fictional code representing the situation: class CreateUserTypes < ActiveRecord::Migration def self.up create_table :user_types do |t| t.string :name, :nil => false, :unique => true end #Create basic types (can not put in seed, because of future migration dependency) UserType.create!(:name => "BASIC") UserType.create!(:name => "MODERATOR") UserType.create!(:name => "ADMINISTRATOR") end def self.down drop_table :user_types end end class AddTypeIdToUsers < ActiveRecord::Migration def self.up add_column :users, :type_id, :integer #Determine type via the admin flag basic = UserType.find_by_name("BASIC") admin = UserType.find_by_name("ADMINISTRATOR") User.all.each {|u| u.update_attribute(:type_id, (u.admin?) ? admin.id : basic.id)} #Remove the admin flag remove_column :users, :admin #Add foreign key execute "alter table users add constraint fk_user_type_id foreign key (type_id) references user_types (id)" end def self.down #Re-add the admin flag add_column :users, :admin, :boolean, :default => false #Reset the admin flag (this is the problematic update code) admin = UserType.find_by_name("ADMINISTRATOR") execute "update users set admin=true where type_id=#{admin.id}" #Remove foreign key constraint execute "alter table users drop foreign key fk_user_type_id" #Drop the type_id column remove_column :users, :type_id end end As you can see there are two problematic parts. First the row creation part in the first model, which is necessary if I would like to run all migrations in a row, then the "update" part in the second migration that maps the "admin" column to the "type_id" column. Any advice?

    Read the article

  • Perl: Unsuccessful stat on filename containing newline. What?

    - by Daniel
    Hello, I am getting an error I do not understand. I am using File:find to recurse a fylesystem on windows using Activestate Perl 5.8.8 and trying to stat $File::Find::name; so I am not stat-ing a filename got from a text file scanning requiring chomp-ing or newline removing. I was unable to get file modification time, the m in: my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($File::Find::name); so trying a -s $File::Find::name give me the error: "Unsuccessful stat on filename containing newline" A typical file name found is F01-01-10 Num 0-00000.pdf but I get the same error even renaming in E02.pdf Some ideas about a possible reason for this error?

    Read the article

  • Add/remove UILocalNotification based on changes in my settings bundle

    - by Daniel Chui
    I have an app that sends a notification at the same time everyday, reminding the user to enter data into it. However, I want to give the user teh option to disable this as this could get very annoying, so I have an "Enable alerts" in a custom settings bundle. My question is, when the user toggles the switch in the settings bundle, can I add/remove the notifications that are already scheduled without having to enter the app again? note: I'm building and supporting for iOS 4.2.1, and I don't konw why but under "notifications" in the settings app, my app does not appear. I see it on ios 5.x devices though

    Read the article

  • How to set the Windows Mobile 6 IME mode (to numbers only)

    - by Daniel Crenna
    In Windows Mobile 5 one of the following methods works to set an input to numbers only: // Managed InputModeEditor.SetInputMode(textBox, InputMode.Numeric); // Native Wrapper InputModeSupport.SHSetImeMode(textBox.Handle, InputModeSupport.SHIME_MODE.SHIME_MODE_NUMBERS); In Windows Mobile 6, neither works. How do you set the IME to "Numbers Only" in WM 6.0 / .NET CF 3.5?

    Read the article

  • How can I write a file on an ftps-server with PHP?

    - by Daniel
    Hi, I hope someone here could help me, because I couldn't find any solution with Google. What I have to do is to generate a XML-string (that works) an save that directly into a file on an ftps-server. So far, so good... I used the following code with ftp and it works to, but not with ftps. So I either need another options-configuration for the stream or a different way to solve that task. Here my current code: $host = 'ftp.example.com'; $port = 22; $user = 'xxxxxx'; $pass = 'xxxxxx'; $file = 'test_' . time() . '.txt'; $ftpPath = sprintf('ftp://%s:%s@%s:%d/%s', $user, $pass, $host, $port, $file); $context = stream_context_create(array('ftp' = array('overwrite' = true))); file_put_contents($ftpPath, 'test', 0, $context);

    Read the article

  • The Immerman-Szelepcsenyi Theorem

    - by Daniel Lorch
    In the Immerman-Szelepcsenyi Theorem, two algorithms are specified that use non-determinisim. There is a rather lengthy algorithm using "inductive counting", which determines the number of reachable configurations for a given non-deterministic turing machine. The algorithm looks like this: Let m_{i+1}=0 For all configurations C Let b=0, r=0 For all configurations D Guess a path from I to D in at most i steps If found Let r=r+1 If D=C or D goes to C in 1 step Let b=1 If r<m_i halt and reject Let m_{i+1}=m_{i+1}+b I is the starting configuration. m_i is the number of configurations reachable from the starting configuration in i steps. This algorithm only calculates the "next step", i.e. m_i+1 from m_i. This seems pretty reasonable, but since we have nondeterminisim, why don't we just write: Let m_i = 0 For all configurations C Guess a path from I to C in at most i steps If found m_i = m_i + 1 What is wrong with this algorithm? I am using nondeterminism to guess a path from I to C, and I verify reachability I am iterating through the list of ALL configurations, so I am sure to not miss any configuration I respect space bounds I can generate a certificate (the list of reachable configs) I believe I have a misunderstanding of the "power" of non-determinisim, but I can't figure out where to look next. I am stuck on this for quite a while and I would really appreciate any help.

    Read the article

  • Setting Mnemonics and Hot Keys for a JOptionPane Dialog

    - by Daniel Bingham
    Is it possible to assign hotkeys and mnemonics to the buttons in a JOptionPane Dialog? I'd like to be able, in a JOptionPane generated message dialog with the options Yes, No and Cancel, press Y to hit the Yes button, N to hit the No button and escape to activate the escape button. Similarly in a dialog with Okay and Cancel buttons I'd like to be able to activate them with enter and escape. I've attempted passing JButtons into the JOptionPane's button Object array with the Mnemonics set already. The mnemonics work and the buttons show up correctly in the dialogs, however, they do not act properly when they are activated. Most noticeably they do not dispose of the dialog. What is the correct way to add hotkeys and Mnemonics to a JOptionPane Dialog's buttons? As always, my apologies ahead of time if this is a duplicate - I searched both Google and Stackoverflow and found nothing.

    Read the article

  • HTML list wrapping problem

    - by Daniel
    I have a HTML list with this style: font-weight: bold; padding: 0px; margin: 0px; list-style-type: none; display: block; width:700px; font-size: 14px; white-space: pre-wrap; and the cells have this style: display: inline; and I have spacer cells between each cell with this style: padding-right: 20px; display: inline; My problem is that when the list is too long for its 700 pixels, it wraps. I want this, but I dont want the objects to be on two separate lines. I have tried the CSS white-space property, but nothing seems to work. Any ideas?

    Read the article

  • artsexylightbox problem when using IE8

    - by Daniel
    I'm using the art sexy lightbox for my pictures presentation and also for html content in joomla. I'm using the Chrome and it works fine and displays everything as it should. The problem starts when i switch to ie8. When i click on the image to xpand in the lightbox the image displays in the center of the page while the thole frame of the picture is on the left of the image. I've tried playing with the artsexylightbox css file but couldnt get it to work in both browsers. does anyone can say why is the difference? I suspect that the browsers treat the absolute,relative orders differently. please help:(

    Read the article

  • what's the purpose of fcntl with parameter F_DUPFD

    - by Daniel
    I traced an oracle process, and find it first open a file /etc/netconfig as file handle 11, and then duplicate it as 256 by calling fcntl with parameter F_DUPFD, and then close the original file handle 11. Later it read using file handle 256. So what's the point to duplicate the file handle? Why not just work on the original file handle? 12931: 0.0006 open("/etc/netconfig", O_RDONLY|O_LARGEFILE) = 11 12931: 0.0002 fcntl(11, F_DUPFD, 0x00000100) = 256 12931: 0.0001 close(11) = 0 12931: 0.0002 read(256, " # p r a g m a i d e n".., 1024) = 1024 12931: 0.0003 read(256, " t s t p i _ c".., 1024) = 215 12931: 0.0002 read(256, 0x106957054, 1024) = 0 12931: 0.0001 lseek(256, 0, SEEK_SET) = 0 12931: 0.0002 read(256, " # p r a g m a i d e n".., 1024) = 1024 12931: 0.0003 read(256, " t s t p i _ c".., 1024) = 215 12931: 0.0003 read(256, 0x106957054, 1024) = 0 12931: 0.0001 close(256) = 0

    Read the article

  • Action property of interface type

    - by Daniel
    Hi, guys. With my understading, the nature of a Action is that properties can be pushed w/ request parameter values. And, one wonderful feature is that Struts2 allows you to directly populate parameter values against Class type property ;) Assuming there exists a Action and property class as below, class Action extends ActionSupport { User user; @Action(value="hello" {@result=(.......)}) public void execute() { ........ } ..... public void setUser(User user) { this.user = user; } public User getUser() { return this.user; } } class User { String name; ..... public void setName(String name) { this.name = name; } public String getName() { return this.name; } } you could populate User class property by doing like this. http://...../hello.action?user.name=John or via jsp page Then, I realize that there are actually people make an Action property as a Interface type. My question is what is the reason behind this. If there is a sample code demonstrating it will be great. Thanks in advance!

    Read the article

  • How to know which process hold a semnum with a specific number?

    - by Daniel
    For the following truss output, we can see the process post to 11 processes whose semnum is 49,32, ..etc, is there anyway to find out which process hold semnum 49, and which process holds setnum32, etc? /1: semop(67108928, 0xFFFFFFFF7FFF9F4C, 11) = 0 /1: semnum=49 semop=1 semflg=0 /1: semnum=32 semop=1 semflg=0 /1: semnum=52 semop=1 semflg=0 /1: semnum=41 semop=1 semflg=0 /1: semnum=40 semop=1 semflg=0 /1: semnum=55 semop=1 semflg=0 /1: semnum=46 semop=1 semflg=0 /1: semnum=35 semop=1 semflg=0 /1: semnum=37 semop=1 semflg=0 /1: semnum=48 semop=1 semflg=0 /1: semnum=39 semop=1 semflg=0

    Read the article

  • Getting Raw XML From SOAPMessage in Java

    - by Daniel Lew
    I've set up a SOAP WebServiceProvider in JAX-WS, but I'm having trouble figuring out how to get the raw XML from a SOAPMessage (or any Node) object. Here's a sample of the code I've got right now, and where I'm trying to grab the XML: @WebServiceProvider(wsdlLocation="SoapService.wsdl") @ServiceMode(value=Service.Mode.MESSAGE) public class SoapProvider implements Provider<SOAPMessage> { public SOAPMessage invoke(SOAPMessage msg) { // How do I get the raw XML here? } } Is there a simple way to get the XML of the original request? If there's a way to get the raw XML by setting up a different type of Provider (such as Source), I'd be willing to do that, too.

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >