Daily Archives

Articles indexed Sunday May 2 2010

Page 16/69 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • removing dependancy of a private function inside a public function using Rhino Mocks

    - by L G
    Hi All, I am new to mocking, and have started with Rhino Mocks. My scenario is like this..in my class library i have a public function and inside it i have a private function call, which gets output from a service.I want to remove the private function dependency. public class Employee { public virtual string GetFullName(string firstName, string lastName) { string middleName = GetMiddleName(); return string.Format("{0} {2} {1}", firstName, lastName,middleName ); } private virtual string GetMiddleName() { // Some call to Service return "George"; } } This is not my real scenario though, i just wanted to know how to remove dependency of GetMiddleName() function and i need to return some default value while unit testing. Note : I won't be able to change the private function here..or include Interface..Keeping the functions as such, is there any way to mock this.Thank

    Read the article

  • useful customize/enhanced php functions that make thing easy and better

    - by I Like PHP
    Hello All, i like to work in php bcoz it's just amazing language. please share basic, useful, enhanced and customize function that make things better and easy in php and must be used in our all PHP project, i m sharing some of them please share your customize function that may be useful for everyone alternative/ enhanced print_r() and var_dump() function watch( $what ) { echo '<pre>'; if ( is_array( $what ) ) { print_r ( $what ); } else { var_dump ( $what ); } echo '</pre>'; } usage: 1. watch($_POST); // to see all post variable 2. watch($array); // to see any variable may b array, string or a variable enhanced mysql_escape_string() for multidimensional array to prevent sql injection function recursive_escape(&$value) { if (is_array($value)) array_map('recursive_escape', $value); else $value = mysql_escape_string($value); } usage array_map('recursive_escape', $_POST); ---------------------For encoding Get variables-------------------------------------- function nkode($k) { if ( is_array( $k ) ) return array_map("base64_encode",$k); else return base64_encode($k); } ---------------------for decoding varaibles from GET--------------------------------- function dkode($k) { if ( is_array( $k ) ) return array_map("base64_decode",$k); else return base64_decode($k); } Usage <a href="somelink.php?pid=<?php echo nkode($someid)?>"> and on next page(somelink.php) $findID=dkode($_GET[pid]); date convert to mm/dd/yyyy to yyyy-mm-dd( if we use date datatype in mysql) and also change into mm/dd/yyyy to disply on page function dateconvert($date,$func) { if ($func == 1){ //insert conversion list($month, $day, $year) = split('[/.-]', $date); $date = "$year-$month-$day"; return $date; } if ($func == 2){ //output conversion list($year, $month, $day) = split('[-.]', $date); $date = "$month/$day/$year"; return $date; } } usage $firstDate=dateconvert($_POST['firstdate'],1); // for insertion in database $showDate=dateconvert($fetch->date_field,2) // to display on browser to clean(sql injection proof) data before doing some action with that variable function cleandata($data) { $success=0; $data=trim($data); $data=strtolower($data); $data=strip_tags($data); return $data; } usage cleandata($_POST[username]); cleandata($_GET[pid]); please share any basic function that must be used , Thanks

    Read the article

  • Rails autlogic : How to make Levels?

    - by Oluf Nielsen
    Hello, i followed this tutorial fo setting Autlogic up properly. So, my site needs a form of level, like "Admin", "Moderator", "User", "Guest". So Admins can do everything, where Moderators may not can make site changes. And Users can't destroy, Update or Create. I've have googled a bit.. But nothing found, so i thought you guys might can help me out? Thank you.

    Read the article

  • jQuery: click() not working in IE 7

    - by Patrick
    hello, I cannot make the click() function work in IE7, for the tags links on the top of the page in this website: http://www.sanstitre.ch/drupal/portfolio?tid[0]=38 Everything works perfectly in other browsers and, the z-index of the header is bigger than the rest of the content. thanks

    Read the article

  • DOM accessing element JS

    - by Michael
    Given the following xml <rss> <channel> ... <pubDate>20/30/2099</pubDate> ... <item> ... <pubDate>10/30/2099</pubDate> ... </item> ... <item> ... <pubDate>40/30/2099</pubDate> ... </item> ... <channel> </rss> how would I efficiently access pudDate in channel and items as array, as well as pudDate in that array.

    Read the article

  • IE8 error when using dyanamic form actions

    - by user330711
    Hello all: Please go here to see an iframe based web app. Click on the map of Australia, choose a city, then buy some tickets. Now you will see the cart form located on the lower right corner. The problem is in IE8, I cannot delete checked rows from the table; whereas in other browsers such as FireFox3.6, Opera10, Safari4 and Chrome4, this action is all right. Below is the related javascript. It doesn't use jQuery, as part of the requirement is no framework allowed! And iframes are the my best bet, ajax will simply kill me under this restriction. /* cartForm.js */ function toDeleteRoutes() //this function is executed before form is to be submitted. { if(document.getElementsByClassName('delete_box').length > 0) //there're rows to delete { document.getElementById('cartForm').action ="./deleteRoutes.php"; document.getElementById('cartForm').target ="section4"; return true; //this enables the form to be submitted as usual. } else return false; //there is no more row in table to delete! } function toSendEmail() //this function is executed before form is to be submitted. { document.getElementById('cartForm').action ="./sendEmail.php"; document.getElementById('cartForm').target ="section3"; document.getElementById('delete_btn').disabled = true; //disable delete button now return true; //this enables the form to be submitted as usual. } function toCancelPurchase() { document.getElementById('cartForm').action ="./cancelPurchase.php"; document.getElementById('cartForm').target ="section4"; return true; //this enables the form to be submitted as usual. } I don't know which part is wrong, or this is just because IE8 screws all?

    Read the article

  • including php file from another server with php

    - by ermac2014
    hi I have 2 php files each file on different server. lets say the first file called includeThis.php and the second called main.php the first file is located in (http://)www.sample.com/includeThis.php and the second located in (http://)www.mysite.com/main.php so now what I want is to include the first file into my second file. the contents of the first file is like: <?php $foo = "this is data from file one"; ?> the second file like: <?php include "http://www.sample.com/includeThis.php"; echo $foo; ?> is there any way I can do this? thanks in advance

    Read the article

  • Why is it so hard to build a gtk programe without console using gtk in windows?

    - by Runner
    I'm following the tuto: http://zetcode.com/tutorials/gtktutorial/firstprograms/ It works but each time I double click on the executable,there is a console which I don't want it there. How do I get rid of that console? I tried this: add_executable(Cmd WIN32 cmd.c) But got this fatal error: MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup Cmd.exe : fatal error LNK1120: 1 unresolved externals While using gcc directly works: gcc -o Cmd cmd.c -mwindows .. I'm guessing it has something to do with the entry function: int main( int argc, char *argv[]),but why gcc works? How can I make it work with cmake?

    Read the article

  • How to calculate the correct image size in out pdf using itextsharp ?

    - by MK
    I' am trying to add an image to a pdf using itextsharp, regardless of the image size it always appears to be mapped to a different greater size inside the pdf ? The image I add is 624x500 pixel (DPI:72): And here is a screen of the output pdf: And here is how I created the document: Document document = new Document(); System.IO.MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); System.Drawing.Image pngImage = System.Drawing.Image.FromFile("test.png"); Image pdfImage = Image.GetInstance(pngImage, System.Drawing.Imaging.ImageFormat.Png); document.Add(pdfImage); document.Close(); byte[] buffer = stream.GetBuffer(); FileStream fs = new FileStream("test.pdf", FileMode.Create); fs.Write(buffer, 0, buffer.Length); fs.Close(); Any idea why on how to calculate the correct size ?

    Read the article

  • Rails multi level model security

    - by rballz
    I have the need to do the following in Rails to mirror a desktop application: a User and an Office 'owns' a record, if you don't own the record on a user or office level you're kicked into the public realm. user gets read,write,delete to the model record office gets read/write/delete to the model record other or public gets read/write/delete to the model record e.g. UserA owns a model record with read/write/delete OfficeA owns a model with read/write other/public gets read I was wondering if a plugin/gem existed to grant this functionality?

    Read the article

  • JPA returning null for deleted items from a set

    - by Jon
    This may be related to my question from a few days ago, but I'm not even sure how to explain this part. (It's an entirely different parent-child relationship.) In my interface, I have a set of attributes (Attribute) and valid values (ValidValue) for each one in a one-to-many relationship. In the Spring MVC frontend, I have a page for an administrator to edit these values. Once it's submitted, if any of these fields (as <input> tags) are blank, I remove the ValidValue object like so: Set<ValidValue> existingValues = new HashSet<ValidValue>(attribute.getValidValues()); Set<ValidValue> finalValues = new HashSet<ValidValue>(); for(ValidValue validValue : attribute.getValidValues()) { if(!validValue.getValue().isEmpty()) { finalValues.add(validValue); } } existingValues.removeAll(finalValues); for(ValidValue removedValue : existingValues) { getApplicationDataService().removeValidValue(removedValue); } attribute.setValidValues(finalValues); getApplicationDataService().modifyAttribute(attribute); The problem is that while the database is updated appropriately, the next time I query for the Attribute objects, they're returned with an extra entry in their ValidValue set -- a null, and thus, the next time I iterate through the values to display, it shows an extra blank value in the middle. I've confirmed that this happens at the point of a merge or find, at the point of "Execute query ReadObjectQuery(entity.Attribute). Here's the code I'm using to modify the database (in the ApplicationDataService): public void modifyAttribute(Attribute attribute) { getJpaTemplate().merge(attribute); } public void removeValidValue(ValidValue removedValue) { ValidValue merged = getJpaTemplate().merge(removedValue); getJpaTemplate().remove(merged); } Here are the relevant parts of the entity classes: Entity @Table(name = "attribute") public class Attribute { @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "attribute") private Set<ValidValue> validValues = new HashSet<ValidValue>(0); } @Entity @Table(name = "valid_value") public class ValidValue { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "attr_id", nullable = false) private Attribute attribute; }

    Read the article

  • changing restriction on simple type in extended complex type

    - by rotary_engine
    I am trying to create a schema that has 2 address types. The first AdressType requires an element Line 1 to have a value at least 10 characters. The second type OtherAdressType derives from this with the same elements, but does not require a value for Line 1. I've tried different ways but always get schema errors, this error is: Invalid particle derivation by restriction - 'Derived element '{namespace}:Line1' is not a valid restriction of base element '{namespace}:Line1' according to Elt:Elt -- NameAndTypeOK.'. If I add a type xs:string to OtherAdressType:Line1 then I get other errors. <xs:complexType name="AdressType"> <xs:sequence> <xs:element name="Line1" minOccurs="1" maxOccurs="1"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="10" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Line2" type="xs:string" minOccurs="1" maxOccurs="1" /> </xs:sequence> </xs:complexType> <xs:complexType name="OtherAdressType"> <xs:complexContent> <xs:restriction base="AdressType"> <xs:sequence> <xs:element name="Line1" nillable="true"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="0" /> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Line2" type="xs:string" minOccurs="1" maxOccurs="1" /> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType>

    Read the article

  • amazon ec2 assign domain name

    - by user41999
    1.amazonaws doesnt provide dns service? 2.i can only assign static ip through ec2 so the only way to assign domain name is to use third party dns service? which do you all recommend? i need one that able to add SRV

    Read the article

  • Problem with Ctrl key on a hp 2510p

    - by Ernelli
    I have a tricky problem with my corporate Compaq hp 2510p, the ctrl key is not working properly at all times. I belive that it is hooked in some filter chain that processes certain ctrl+[key] combinations which is very annoying. I would like some pointers on how to proceed when analysing what application/setup can can cause this kind of keyboard filtering to happen. Anyway some more background info: Ctrl works together with X, C, V. Both in editors and terminals (Ctrl-C, Z etc) but Ctrl-Shift-Esc and Ctrl-Alt-Del does not work. Very annoying so my only option for logging in us using HP's security app. Shift-Arrow works for selecting text, but not Ctrl-shift arrow to select word by word, but Ctrl-Arrow works when moving the caret word by word. Now the strange thing is that everything works ok with an external USB keyboard so it might be the driver, but still, google yields 0 when searching for the problem description. I have vm-ware player installed (but not running it), HP Protect Tools installed, if any of these could affect the keyboard driver.

    Read the article

  • What are those little useful ,customize/enhanced php functions that you wish you knew about 2 years

    - by I Like PHP
    Hello All, i like to work in php bcoz it's just amazing language. please share basic, useful, enhanced and customize function that make things better and easy in php and must be used in our all PHP project, i m sharing some of them please share your customize function that may be useful for everyone alternative/ enhanced print_r() and var_dump() function watch( $what ) { echo '<pre>'; if ( is_array( $what ) ) { print_r ( $what ); } else { var_dump ( $what ); } echo '</pre>'; } usage: 1. watch($_POST); // to see all post variable 2. watch($array); // to see any variable may b array, string or a variable enhanced mysql_escape_string() for multidimensional array to prevent sql injection function recursive_escape(&$value) { if (is_array($value)) array_map('recursive_escape', $value); else $value = mysql_escape_string($value); } usage array_map('recursive_escape', $_POST); ---------------------For encoding Get variables-------------------------------------- function nkode($k) { if ( is_array( $k ) ) return array_map("base64_encode",$k); else return base64_encode($k); } ---------------------for decoding varaibles from GET--------------------------------- function dkode($k) { if ( is_array( $k ) ) return array_map("base64_decode",$k); else return base64_decode($k); } Usage <a href="somelink.php?pid=<?php echo nkode($someid)?>"> and on next page(somelink.php) $findID=dkode($_GET[pid]); date convert to mm/dd/yyyy to yyyy-mm-dd( if we use date datatype in mysql) and also change into mm/dd/yyyy to disply on page function dateconvert($date,$func) { if ($func == 1){ //insert conversion list($month, $day, $year) = split('[/.-]', $date); $date = "$year-$month-$day"; return $date; } if ($func == 2){ //output conversion list($year, $month, $day) = split('[-.]', $date); $date = "$month/$day/$year"; return $date; } } usage $firstDate=dateconvert($_POST['firstdate'],1); // for insertion in database $showDate=dateconvert($fetch->date_field,2) // to display on browser to clean data before doing some action with that variable function cleanID($data) { $success=0; $data=trim($data); $data=strtolower($data); $data=strip_tags($data); return $data; } usage cleanID($_POST[username]); cleanID($_GET[pid]); please share any basic function that must be used , and please give me some suggestion to make above function more better Thanks

    Read the article

  • Moose::Error::Croak error reporting not from perspective of caller.

    - by crashpoint_zero
    I just recently started out on Moose and its a great OO framework not only to use but also to learn new OO concepts. One of the things I wanted to do was to do error reporting from perspective of caller during object creation. I saw that Moose has the module Moose::Error::Croak which tells Moose to override the default error reporting by croak call. I used it but it did not seem to help Moose code - Foo.pm package Foo; use metaclass ( metaclass => 'Moose::Meta::Class', error_class => 'Moose::Error::Croak', ); use Moose; has 'attr1' => ( is => 'rw', isa => 'Str', required => '1', ); no Moose; 1; Moose code - fooser.pl #!/usr/bin/perl use strict; use warnings; use Foo; my $foobj = Foo->new(); This fails with error: Attribute (attr1) is required at /usr/local/lib/perl/5.8.8/Class/MOP/Class.pm line 364 which is terse than the actual stack trace if Moose::Error::Croak is not used. But it does not report it from perspective of caller. If this were a Perl 5 OO code and I had Foo.pm as: package Foo; use strict; use warnings; use Carp; sub new { my ($class, %args) = @_; my $self = {}; if (! exists $args{'attr1'}) { croak "ERR: did not provide attr1"; } $self->{'attr1'} = $args{attr1}; bless $self, $class; return $self; } 1; And if fooser.pl was executed I would have got the error: "ERR: did not provide attr1 at fooser.pl line 6" which is from the perspective of the caller as it points to line no. 6 of fooser.pl rather than MOP.pm's line no. 364. How can I do this in Moose? Or am I misunderstanding something here?

    Read the article

  • How to pass the values from one activity to previous activity

    - by Kumar
    Dear friends.. Can any one tell me how to pass the value from one screen to its previous screen. Consider the case.i m having two screen first screen with one Textview and button and the second activity have one edittext and button. If i click the first button then it has to move to second activity and here user has to type something in the textbox. If he press the button from the second screen then the values from the textbox should move to the first activity and that should be displayed in the first activity textview. regards, s.kumaran.

    Read the article

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