Search Results

Search found 28563 results on 1143 pages for 'strange but true'.

Page 38/1143 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • C# why unit test has this strange behaviour?

    - by 5YrsLaterDBA
    I have a class to encrypt the connectionString. public class SKM { private string connStrName = "AndeDBEntities"; internal void encryptConnStr() { if(isConnStrEncrypted()) return; ... } private bool isConnStrEncrypted() { bool status = false; // Open app.config of executable. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Get the connection string from the app.config file. string connStr = config.ConnectionStrings.ConnectionStrings[connStrName].ConnectionString; status = !(connStr.Contains("provider")); Log.logItem(LogType.DebugDevelopment, "isConnStrEncrypted", "SKM::isConnStrEncrypted()", "isConnStrEncrypted=" + status); return status; } } Above code works fine in my application. But not in my unit test project. In my unit test project, I test the encryptConnStr() method. it will call isConnStrEncrypted() method. Then exception (null pointer) will be thrown at this line: string connStr = config.ConnectionStrings.ConnectionStrings[connStrName].ConnectionString; I have to use index like this to pass the unit test: string connStr = config.ConnectionStrings.ConnectionStrings[0].ConnectionString; I remember it worked several days ago at the time I added above unit test. But now it give me an error. The unit test is not integrated with our daily auto build yet. We only have ONE connectionStr. It works with product but not in unit test. Don't know why. Anybody can explain to me?

    Read the article

  • very strange thread error message

    - by John Smith
    I an trying to put a method in a separate thread in the background. It nearly works except that occasionally I get a lot of error messages with the message METHODCLOSURE: OH NO SEPERATE THREAD with the bad spelling and all. Does anyone know what this means?

    Read the article

  • node.js - strange behavior of coffeescript compiler

    - by JimBob
    I noticed an unexplainable behavior of the coffeescript compiler for me :) For example: getImage: (req, res) => realty_id = req.query.id if (realty_id?) Result ImageController.prototype.getImage = function(req, res) { var realty_id, _this = this; realty_id = req.query.id; if ((realty_id != null) But actually the last line should be: if ((typeof realty_id !== "undefined" && realty_id !== null)) When I comment out "realty_id = req.query.id" it works well. Has anyone a explanation for that?

    Read the article

  • jQuery: if value is true without user action

    - by Kevin Brown
    I want to show a div if the value of an input =='CP'. Right now this is my code: $(".register-type").change(function(){ var value = $(this).val(); if(value == 'CP'){ $('.cp-show').show(); This works fine if they change the input, but if things get validated false and the page reloads, this input is still 'CP', but the div doesn't show... Is there a way to correct this so that jquery checks if this is set on the page load?

    Read the article

  • Strange numbers in java socket output

    - by user293163
    I have small test app: Socket socket = new Socket("jeck.ru", 80); PrintWriter pw = new PrintWriter(socket.getOutputStream(), false); pw.println("GET /ip/ HTTP/1.1"); pw.println("Host: jeck.ru"); pw.println(); pw.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream())); String str; while ((str = rd.readLine()) != null) { System.out.println(str); } It`s output: HTTP/1.1 200 OK Date: Sat, 13 Mar 2010 22:06:51 GMT Content-Type: text/html;charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Keep-Alive: timeout=5 Server HTTP/1.1 200 OK Date: Sat, 13 Mar 2010 22:06:51 GMT Content-Type: text/html;charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Keep-Alive: timeout=5 Server: Apache Cache-Control: max-age=0 Expires: Sat, 13 Mar 2010 22:06:51 GMT 123 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>??? IP</title> </head> <body> <div style='text-align: center; font: 32pt Verdana;margin-top: 300px'> ??? IP &#151; 94.103.87.153 </div> </body> </html> 0 Whence these numbers (123 an 0) takes?

    Read the article

  • Visual Studio 2005 - strange characters rendered for ANSI text

    - by Apogee
    Hi all, Has anyone seen this odd text rendering issue in VS2005 before? The first line of using statements actually says "using System;". If I copy the line as it is displayed and paste into notepad, the text appears correctly, so clearly the character codes are correct. In addition, the solution compiles and runs correctly. I was thinking it might be due to ClearCase using a different character encoding as all the solutions we're using were freshly checked-out yesterday on to a new build machine, but this is only happening in 2 of our ~30 solutions. Incidentally the same .cs files when opened in VS2008 render correctly on this machine, could this be a corruption in VS2005?

    Read the article

  • .Net in HTML tp return true if reader object not null, otherwise return false

    - by Phill Healey
    I'm using a DataList to show some data from the database and populating the fields on the html side. I now have a requirement to change the visibility of a panel based on whether or not a db field has data or not. I need to be able to show the panel if the relevant data field has content, and hide it if it doesn't. Eg: <asp:Panel ID="pnlNew" runat="server" Style="margin:0; padding:0; width:42px; height:18px; bottom:5px; right:10px; float:right; position:relative; background:url(../_imgVideoBadge.png) no-repeat;" Visible='<%# Eval("cheese") != null %>' ToolTip="available"></asp:Panel> Obviously this doesn't work in terms of the visible property. But hopefully it gives an idea of what I'm trying to achieve. Any help would be greatly appreciated. I've seen examples previously of doing something along the lines of: a ?? b:c How could this be applied to the above requirement?? Thanks in advance.

    Read the article

  • Strange behaviour when simply adding strings in Lazarus - FreePascal

    - by linkcharger
    The program has several "encryption" algorithms. This one should blockwise reverse the input. "He|ll|o " becomes "o |ll|He" (block length of 2). I add two strings, in this case appending the result string to the current "block" string and making that the result. When I add the result first and then the block it works fine and gives me back the original string. But when i try to reverse the order it just gives me the the last "block". Several other functions that are used for "rotation" are above. //amount of blocks function amBl(i1:integer;i2:integer):integer; begin if (i1 mod i2) <> 0 then result := (i1 div i2) else result := (i1 div i2) - 1; end; //calculation of block length function calcBl(keyStr:string):integer; var i:integer; begin result := 0; for i := 1 to Length(keyStr) do begin result := (result + ord(keyStr[i])) mod 5; result := result + 2; end; end; //desperate try to add strings function append(s1,s2:string):string; begin insert(s2,s1,Length(s1)+1); result := s1; end; function rotation(inStr,keyStr:string):string; var //array of chars -> string block,temp:string; //position in block variable posB:integer; //block length and block count variable bl, bc:integer; //null character as placeholder n : ansiChar; begin //calculating block length 2..6 bl := calcBl(keyStr); setLength(block,bl); result := ''; temp := ''; {n := #00;} for bc := 0 to amBl(Length(inStr),bl) do begin //filling block with chars starting from back of virtual block (in inStr) for posB := 1 to bl do begin block[posB] := inStr[bc * bl + posB]; {if inStr[bc * bl + posB] = ' ' then block[posB] := n;} end; //adding the block in front of the existing result string temp := result; result := block + temp; //result := append(block,temp); //result := concat(block,temp); end; end; (full code http://pastebin.com/6Uarerhk) After all the loops "result" has the right value, but in the last step (between "result := block + temp" and the "end;" of the function) "block" replaces the content of "result" with itself completely, it doesn't add result at the end anymore. And as you can see I even used a temp variable to try to work around that.. doesnt change anything though.

    Read the article

  • Strange thing on IPv6 multicast program on Windows

    - by zhanglistar
    I have written an ipv6 multicast program on windows xp sp3. But a problem bothers me a lot. The sendto function implies no error, but I can't capture the packet using wireshark. I am sure the filter is right. Thanks in advance. And the code is as follows: #include "stdafx.h" #include <stdio.h> /* for printf() and fprintf() */ #include <winsock2.h> /* for socket(), connect(), sendto(), and recvfrom() */ #include <ws2tcpip.h> /* for ip_mreq */ #include <stdlib.h> /* for atoi() and exit() */ #include <string.h> /* for memset() */ #include <time.h> /* for timestamps */ #include <pcap.h> #include <Iphlpapi.h> #pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "wpcap.lib") #pragma comment(lib, "Iphlpapi.lib") int _tmain(int argc, _TCHAR* argv[]) { int sfd; int on, length, iResult; WSADATA wsaData; struct addrinfo Hints; struct addrinfo *multicastAddr, *localAddr; char buf[46]; // Initialize Winsock iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); return 1; } /* Resolve destination address for multicast datagrams */ memset(&Hints, 0, sizeof (Hints)); Hints.ai_family = AF_INET6; Hints.ai_socktype = SOCK_DGRAM; Hints.ai_protocol = IPPROTO_UDP; Hints.ai_flags = AI_NUMERICHOST; iResult = getaddrinfo("FF02::1:2", "547", &Hints, &multicastAddr); if (iResult != 0) { /* error handling */ printf("socket error: %d\n", WSAGetLastError()); return -1; } /* Get a local address with the same family (IPv4 or IPv6) as our multicast group */ Hints.ai_family = multicastAddr->ai_family; Hints.ai_socktype = SOCK_DGRAM; Hints.ai_flags = AI_PASSIVE; /* Return an address we can bind to */ if ( getaddrinfo(NULL, "546", &Hints, &localAddr) != 0 ) { printf("getaddrinfo() failed: %d\n", WSAGetLastError()); exit(-1); } // Create sending socket //sfd = socket (multicastAddr->ai_family, multicastAddr->ai_socktype, multicastAddr->ai_protocol); sfd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (sfd == -1) { printf("socket error: %d\n", WSAGetLastError()); return 0; } /* Bind to the multicast port */ if ( bind(sfd, localAddr->ai_addr, localAddr->ai_addrlen) != 0 ) { printf("bind() failed: %d\n", WSAGetLastError()); exit(-1); } if (multicastAddr->ai_family == AF_INET6 && multicastAddr->ai_addrlen == sizeof(struct sockaddr_in6)) /* IPv6 */ { on = 1; if (setsockopt (sfd, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *)&on, sizeof (on) /*(char *)&interface_addr, sizeof(interface_addr)*/) == -1) { printf("setsockopt error:%d\n", WSAGetLastError()); return -1; } if (setsockopt (sfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *)&on, sizeof (on) /*(char *)&interface_addr, sizeof(interface_addr)*/) == -1) { printf("setsockopt error:%d\n", WSAGetLastError()); return -1; } struct ipv6_mreq multicastRequest; /* Multicast address join structure */ /* Specify the multicast group */ memcpy(&multicastRequest.ipv6mr_multiaddr, &((struct sockaddr_in6*)(multicastAddr->ai_addr))->sin6_addr, sizeof(struct in6_addr)); /* Accept multicast from any interface */ multicastRequest.ipv6mr_interface = 0; /* Join the multicast address */ if ( setsockopt(sfd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) != 0 ) { printf("setsockopt() failed: %d\n", WSAGetLastError()); return -1; } on = 1; if (setsockopt (sfd, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *)&on, sizeof (on)) == -1) { printf("setsockopt error:%d\n", WSAGetLastError()); return 0; } } memset(buf, 0, sizeof(buf)); strcpy(buf, "hello world"); iResult = sendto(sfd, buf, strlen(buf), 0, (LPSOCKADDR) multicastAddr->ai_addr, multicastAddr->ai_addrlen); if (iResult == SOCKET_ERROR) { printf("setsockopt error:%d\n", WSAGetLastError()); return -1; /* Error handling */ } return 0; }

    Read the article

  • UITextField placeholder looks strange when UITableViewCellSelectionStyleGray

    - by mongeta
    Hello, I've set the background color of my UITableViewCells to Gray. But if there's a UITextField in the cell, the placeholder doesn't change their color to white/black and it's almost impossible to read it, and look stranges. The UILabel from the cell changes their color when it's selected or not, but the placeholder remains always the same. There's a simple solution ? I don't want to add some UILabel and use it as a placeholder, etc. etc. Thanks, r.

    Read the article

  • True / false evaluation doesn't work as expected in Scheme

    - by ron
    I'm trying to compare two booleans : (if (equal? #f (string->number "123b")) "not a number" "indeed a number") When I run this in the command line of DrRacket I get "not a number" , however , when I put that piece of code in my larger code , the function doesn't return that string ("not a number") , here's the code : (define (testing x y z) (define badInput "ERROR") (if (equal? #f (string->number "123b")) "not a number" "indeed a number") (display x)) And from command line : (testing "123" 1 2) displays : 123 Why ? Furthermore , how can I return a value , whenever I choose ? Here is my "real" problem : I want to do some input check to the input of the user , but the thing is , that I want to return the error message if I need , before the code is executed , because if won't - then I would run the algorithm of my code for some incorrect input : (define (convert originalNumber s_oldBase s_newBase) (define badInput "ERROR") ; Input check - if one of the inputs is not a number then return ERROR (if (equal? #f (string->number originalNumber)) badInput) (if (equal? #f (string->number s_oldBase)) badInput) (if (equal? #f (string->number s_newBase)) badInput) (define oldBase (string->number s_oldBase)) (define newBase (string->number s_newBase)) (define outDecimal (convertIntoDecimal originalNumber oldBase)) (define result "") ; holds the new number (define remainder 0) ; remainder for each iteration (define whole 0) ; the whole number after dividing (define temp 0) (do() ((= outDecimal 0)) ; stop when the decimal value reaches 0 (set! whole (quotient outDecimal newBase)) ; calc the whole number (set! temp (* whole newBase)) (set! remainder (- outDecimal temp)) ; calc the remainder (set! result (appending result remainder)) ; append the result (set! outDecimal (+ whole 0)) ; set outDecimal = whole ) ; end of do (if (> 1 0) (string->number (list->string(reverse (string->list result))))) ) ;end of method This code won't work since it uses another method that I didn't attach to the post (but it's irrelevant to the problem . Please take a look at those three IF-s ... I want to return "ERROR" if the user put some incorrect value , for example (convert "23asb4" "b5" "9") Thanks

    Read the article

  • Python. Strange class attributes behavior

    - by Eugene
    >>> class Abcd: ... a = '' ... menu = ['a', 'b', 'c'] ... >>> a = Abcd() >>> b = Abcd() >>> a.a = 'a' >>> b.a = 'b' >>> a.a 'a' >>> b.a 'b' It's all correct and each object has own 'a', but... >>> a.menu.pop() 'c' >>> a.menu ['a', 'b'] >>> b.menu ['a', 'b'] How could this happen? And how to use list as class attribute?

    Read the article

  • Strange PHP syntax

    - by Joseph
    I've been working on php for some time but today when I saw this it came as new to me: if(preg_match('/foo.*bar/','foo is a bar')): echo 'success '; echo 'foo comes before bar'; endif; To my surprise it also runs without error. Can anyone enlighten me?

    Read the article

  • Strange difference between optimized/non optimized microsoft c++ code

    - by Anders Forsgren
    I have a c++ program with a method that looks something like this: int myMethod(int* arr1, int* arr2, int* index) { arr1--; arr2--; int val = arr1[*index]; int val2 = arr2[val]; doMoreThings(val); } With optimizations enabled (/O2) the first line where the first pointer is decremented is not executed. I assume the compiler believes that the arr1 array is not used since it thinks it can remove the decrement. Am I violating some convention in the above code? What could cause this behavior? It is a very old piece of f2c-translated code, the pointer decrement is due to the 1-based indexing of the original code.

    Read the article

  • Non-CDN hosted jQuery caused some strange behaviour

    - by kwokwai
    Hi all, I was using this JQuery in this download link, and included it in the head tag of a HTML web page: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> In a php web page, I got these few lines of codes: $.ajax({ url: 'http://mywebsite.com/site1/toavail/, type: "post", success: function(data) { // some more code here } }); When I tested the HTML page in IE 6, and 7, I saw the same warning message: "permission denied" When I tested it in Firefox 3, nothing was returned from the server web page. Later, I changed the JQuery source link to be: http://code.jquery.com/jquery-1.4.2.js I refreshed the web page, and I could saw the returned value then.

    Read the article

  • Strange thread behavior in Perl

    - by Zaid
    Tom Christiansen's example code (à la perlthrtut) is a recursive, threaded implementation of finding and printing all prime numbers between 3 and 1000. Below is a mildly adapted version of the script #!/usr/bin/perl # adapted from prime-pthread, courtesy of Tom Christiansen use strict; use warnings; use threads; use Thread::Queue; sub check_prime { my ($upstream,$cur_prime) = @_; my $child; my $downstream = Thread::Queue->new; while (my $num = $upstream->dequeue) { next unless ($num % $cur_prime); if ($child) { $downstream->enqueue($num); } else { $child = threads->create(\&check_prime, $downstream, $num); if ($child) { print "This is thread ",$child->tid,". Found prime: $num\n"; } else { warn "Sorry. Ran out of threads.\n"; last; } } } if ($child) { $downstream->enqueue(undef); $child->join; } } my $stream = Thread::Queue->new(3..shift,undef); check_prime($stream,2); When run on my machine (under ActiveState & Win32), the code was capable of spawning only 118 threads (last prime number found: 653) before terminating with a 'Sorry. Ran out of threads' warning. In trying to figure out why I was limited to the number of threads I could create, I replaced the use threads; line with use threads (stack_size => 1);. The resultant code happily dealt with churning out 2000+ threads. Can anyone explain this behavior?

    Read the article

  • Strange attribute in DIV tag

    - by user433500
    I am seeing some attribute I have never seen before in a div tag. I haven't touch html for a while but googling the attribute didn't return much useful info. <div dataquery="#item_1306" comp="box.components.Flashplayer" id="box_Flashplayer_2" propertyquery="#box_Flashplaye_2" class="box_Flashplaye_style2"... My question is, do you know what are these "dataquery" "comp" and "propertyquery" attributes? Thanks alot folks.

    Read the article

  • mysqli::query returns true on SELECT statement

    - by Travis Pessetto
    I have an application that reads in one of its classes: public function __construct() { global $config; //Establish a connection to the database and get results set $this->db = new Database("localhost",$config["dbuser"],$config["dbpass"],"student"); $this->records = $this->db->query("SELECT * FROM major") or die("ERROR: ".$this->db->error); echo "<pre>".var_dump($this->records)."</pre>"; } My problem is that var_dump shows that $this->records is a boolean. I've read the documentation and see that the SELECT query should return a result set. This is the only query used by the application. Any ideas where I am going wrong?

    Read the article

  • Strange compiler complaint when using similar code

    - by Jason
    For a project, I have to ask the user for a file name, and I'm reading it in character by character using getchar. From the main, I call the function char *coursename= introPrint(); //start off to print the usage directions and get the first bit of input. That function is defined as char *introPrint(){ int size= 20; int c; int length=0; char buffer[size]; //instructions printout, cut for brevity //get coursename from user and return it while ( (c=getchar()) != EOF && (c != '\n') ){ buffer[length++]= c; if (length==size-1) break; } buffer[length]=0; return buffer; } This is basically identical code I wrote to ask the user for input, replace the character echo with asterisks, then print out the results. Here, though, I'm getting a function returns address of local variable warning for the return statement. So why am I getting no warnings from the other program, but trigger one for this code?

    Read the article

  • Strange performance behaviour

    - by plastilino
    I'm puzzled with this. In my machine Direct calculation: 375 ms Method calculation: 3594 ms, about TEN times SLOWER If I place the method calulation BEFORE the direct calculation, both times are SIMILAR. Woud you check it in your machine? class Test { static long COUNT = 50000 * 10000; private static long BEFORE; /*--------METHOD---------*/ public static final double hypotenuse(double a, double b) { return Math.sqrt(a * a + b * b); } /*--------TIMER---------*/ public static void getTime(String text) { if (BEFORE == 0) { BEFORE = System.currentTimeMillis(); return; } long now = System.currentTimeMillis(); long elapsed = (now - BEFORE); BEFORE = System.currentTimeMillis(); if (text.equals("")) { return; } String message = "\r\n" + text + "\r\n" + "Elapsed time: " + elapsed + " ms"; System.out.println(message); } public static void main(String[] args) { double a = 0.2223221101; double b = 122333.167; getTime(""); /*--------DIRECT CALCULATION---------*/ for (int i = 1; i < COUNT; i++) { Math.sqrt(a * a + b * b); } getTime("Direct: "); /*--------METHOD---------*/ for (int k = 1; k < COUNT; k++) { hypotenuse(a, b); } getTime("Method: "); } }

    Read the article

  • Strange text when converting XML array to XML

    - by danit
    Im using the answer to this question to convert an array of XML to a single XML output: http://stackoverflow.com/questions/2554671/output-array-of-xml-to-plain-xml Im using the simpler solution of the two there (Marked as the answer) It all works for me, however at the start of the output I get: string(109960) " Can anyone shed any light on this? Output here: http://bit.ly/aoA3qY

    Read the article

  • Strange overloading rules in C++

    - by bucels
    I'm trying to compile this code with GCC 4.5.0: #include <algorithm> #include <vector> template <typename T> void sort(T, T) {} int main() { std::vector<int> v; sort(v.begin(), v.end()); } But it doesn't seem to work: $ g++ -c nm.cpp nm.cpp: In function ‘int main()’: nm.cpp:9:28: error: call of overloaded ‘sort(std::vector<int>::iterator, std::vector<int>::iterator)’ is ambiguous nm.cpp:4:28: note: candidates are: void sort(T, T) [with T = __gnu_cxx::__normal_iterator<int*, std::vector<int> >] /usr/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/stl_algo.h:5199:69: note: void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >] Comeau compiles this code without errors. (4.3.10.1 Beta2, strict C++03, no C++0x) Is this valid C++?

    Read the article

  • Strange exception phenomenon in Windows 7

    - by Level 2
    I spot some interesting articles about exception handle in CodeProject http://www.codeproject.com/KB/cpp/seexception.aspx After reading, I decided to do some experiment. The first time I try to execute the following code char *p; p[0] = 0; The program died without question. But After several times when I executed the same problem binary code, it magically did fine. Even the following code is doing well. Any clue or explanation? char *p p[1000] = 'd'; cout<<p[1000]<<endl; My O/S is Windows 7 64bit and compiler is VS2008 rc1.

    Read the article

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