Daily Archives

Articles indexed Wednesday April 7 2010

Page 12/131 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • What do you call the << operator in Ruby when it's used for appending stuff?

    - by more or less
    In other contexts I know this << is called the bitshift operator. Is there a name for it when it's just used for append operations like you would do in an array or string (not sure what else you can append with it)? I'd like to be able to use an English word to refer to it instead of saying "you know, the operator with the two left arrows that's not really the left bitshift operator".

    Read the article

  • How can I monitor if a cookie is being sent to a domain other than the one it originated from?

    - by Brendan Salt
    I am trying to write a program that will verify that all cookies sent out from the machine are in fact going to the domain they came from. This is part of a larger security project to detect cookie based malicious attacks (such as XSS). The main snag for this project is actually detecting the out-going cookies. Can someone point me in the right direction for monitoring out-going HTTP traffic for cookie information? Other information about the project: This is a windows application written in C and numerous scripting languages. Thanks so much for the help.

    Read the article

  • sOperator as and generic classes

    - by abatishchev
    I'm writing .NET On-the-Fly compiler for CLR scripting and want execution method make generic acceptable: object Execute() { return type.InvokeMember(..); } T Execute<T>() { return Execute() as T; /* doesn't work: The type parameter 'T' cannot be used with the 'as' operator because it does not have a class type constraint nor a 'class' constraint */ // also neither typeof(T) not T.GetType(), so on are possible return (T) Execute(); // ok } But I think operator as will be very useful: if result type isn't T method will return null, instead of an exception! Is it possible to do?

    Read the article

  • Comparing Tuples in SQL

    - by Brad
    Is there any more convenient way to compare a tuple of data in T-SQL than doing something like this: SELECT TOP 100 A, B FROM MyTable WHERE (A > @A OR (A = @A AND B > @B)) ORDER BY A, B Basically I'm looking for rows with (A, B) (@A, @B) (the same ordering as I have in the order by clause). I have cases where I have 3 fields, but it just gets even uglier then.

    Read the article

  • How does delete deal with pointer constness?

    - by aJ
    I was reading this question Deleting a const pointer and wanted to know more about delete behavior. Now, as per my understanding: delete expression works in two steps: invoke destructor then releases the memory (often with a call to free()) by calling operator delete. operator delete accepts a void*. As part of a test program I overloaded operator delete and found that operator delete doesn't accept const pointer. Since operator delete does not accept const pointer and delete internally calls operator delete, how does Deleting a const pointer work ? Does delete uses const_cast internally?

    Read the article

  • The ternary (conditional) operator in C

    - by Bongali Babu
    What is the need for the conditional operator? Functionally it is redundant, since it implements an if-else construct. If the conditional operator is more efficient than the equivalent if-else assignment, why can't if-else be interpreted more efficiently by the compiler?

    Read the article

  • Understanding evaluation of expressions containing '++' and '->' operators in C.

    - by Leif Ericson
    Consider this example: struct { int num; } s, *ps; s.num = 0; ps = &s; ++ps->num; printf("%d", s.num); /* Prints 1 */ It prints 1. So I understand that it is because according to operators precedence, -> is higher than ++, so the value ps->num (which is 0) is firstly fetched and then the ++ operator operates on it, so it increments it to 1. struct { int num; } s, *ps; s.num = 0; ps = &s; ps++->num; printf("%d", s.num); /* Prints 0 */ In this example I get 0 and I don't understand why; the explanation of the first example should be the same for this example. But it seems that this expression is evaluated as follows: At first, the operator ++ operates, and it operates on ps, so it increments it to the next struct. Only then -> operates and it does nothing because it just fetches the num field of the next struct and does nothing with it. But it contradicts the precedence of operators, which says that -> have higher precedence than ++. Can someone explain this behavior? Edit: After reading two answers which refer to a C++ precedence tables which indicate that a prefix ++/-- operators have lower precedence than ->, I did some googling and came up with this link that states that this rule applies also to C itself. It fits exactly and fully explains this behavior, but I must add that the table in this link contradicts a table in my own copy of K&R ANSI C. So if you have suggestions as to which source is correct I would like to know. Thanks.

    Read the article

  • Change the contrast of Image like Adobe Photoshop in ASP.net C#

    - by Hoque
    While I was trying to change the brightness and contrast of Image using C#, but I could not get success in changing the contrast of the Image. May I expect any support from here. I am using ColorMatrix to do that. Here are the code that I am using for brightness(works fine) and contrast(does not work properly). public static ColorMatrix CreateBrightnessMatrix(float Brightness) { if (Brightness < -1 || Brightness > 1) throw new ArgumentOutOfRangeException("Brightness value is out of range"); ColorMatrix cm = new ColorMatrix(new float[][]{ new float[] { 1f, 0, 0, 0, 0}, new float[] { 0, 1f, 0, 0, 0}, new float[] { 0, 0, 1f, 0, 0}, new float[] { 0, 0, 0, 1f, 0}, new float[] {Brightness, Brightness, Brightness, 1f, 1f}}); return cm; } public static ColorMatrix CreateContrastMatrix(float Contrast) { if (Contrast < 0 || Contrast > 3) throw new ArgumentOutOfRangeException("Contrast value is out of range"); float Trans = (1f - Contrast) / 2f; ColorMatrix cm = new ColorMatrix(new float[][]{ new float[] {Contrast, 0f, 0f, 0f, 0f}, new float[] { 0f, Contrast, 0f, 0f, 0f}, new float[] { 0f, 0f, Contrast, 0f, 0f}, new float[] { 0f, 0f, 0f, 1f, 0f}, new float[] { Trans, Trans, Trans, 0f, 1f}}); return cm; } Thanks.

    Read the article

  • C# what does the == operator do in detail?

    - by clamp
    in c# what does exactly happen in the background when you do a comparison with the "==" operator on two objects? does it just compare the addresses? or does it something like Equals() or CompareTo() ? PS: what about the "==" operator in java? does it behave the same?

    Read the article

  • Cheatsheet: 2010 04.01 ~ 04.07

    - by gOODiDEA
    Web Web Performance Best Practices: How masters.com re-designed their site to boost performance – and what that re-design missed What’s wrong with extending the DOM John Resig on Advanced Javascript to Improve your Web App .NET Hammock for REST - a REST library for .NET Programming Windows Phone 7 Series by Charlez Petzold – Free EBook Testing the Lock-Free Queue Some Last-Minute New C# 4.0 Features - while (x --> 0) { Console.WriteLine("x = {0}", x); } Better Coding with Visual Studio 2010 Revisiting Asynchronous ASP.NET Pages Database Understanding RAID for SQL Server – Part 2 Cassandra Jump Start For The Windows Developer Cassandra Internals – Writing - Cassandra Write Operation Performance Explained Cassandra Internals – Reading - Cassandra Reads Performance Explained MongoDB Growing Up: Release 1.4 and Commercial Support by 10gen Why NoSQL Will Not Die How Many Hard Drives Do I Need to Support SQL Server? Other Presentation: CouchDB and Lucene MongoDB Cacti Graphs HBase vs Cassandra: why we moved How to use the DedicatedDumpFile registry value to overcome space limitations on the system drive when capturing a system memory dump

    Read the article

  • Integers not properly returned from a property list (plist) array in Objective-C

    - by Gaurav
    In summary, I am having a problem where I read what I expect to be an NSNumber from an NSArray contained in a property list and instead of getting a number such as '1', I get what looks to be a memory address (i.e. '61879840'). The numbers are clearly correct in the property list. Below is my process for creating the property list and reading it back. Creating the property list I have created a simple Objective-C property list with arrays of integers within one root array: <array> <array> <integer>1</integer> <integer>2</integer> </array> <array> <integer>1</integer> <integer>2</integer> <integer>5</integer> </array> ... more arrays with integers ... </array> The arrays are NSArray objects and the integers are NSNumber objects. The property list has been created and serialized using the following code: // factorArray is an NSArray that contains NSArrays of NSNumbers as described above // serialize and compress factorArray as a property list, Factors-bin.plist NSString *error; NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Factors-bin.plist"]; NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:factorArray format:NSPropertyListBinaryFormat_v1_0 errorDescription:&error]; Inspecting the created plist, all values and types are correct. Reading the property list The property list is read in as Data and then converted to an NSArray: NSString *path = [[NSBundle mainBundle] pathForResource:@"Factors" ofType:@"plist"]; NSData *plistData = [[NSData alloc] initWithContentsOfFile:path]; NSPropertyListFormat format; NSString *error = nil; NSArray *factorData = (NSArray *)[NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; Cycling through factorData to see what it contains is where I see the erroneous integers: for (int i = 0; i < 10; i++) { NSArray *factorList = (NSArray *)[factorData objectAtIndex:i]; NSLog(@"Factors of %d\n", i + 1); for (int j = 0; j < [factorList count]; j++) { NSLog(@" %d\n", (NSNumber *)[factorList objectAtIndex:j]); } } I see all the correct number of values, but the values themselves are incorrect, i.e.: Factors of 3 61879840 (should be 1) 61961200 (should be 3) Factors of 4 61879840 (should be 1) 61943472 (should be 2) 61943632 (should be 4) Factors of 5 61879840 (should be 1) 61943616 (should be 5)

    Read the article

  • Dynamically created operators

    - by Gero
    I created a program using dev-cpp and wxwidgets which solves a puzzle. The user must fill the operations blocks and the results blocks, and the program will solve it. Im solving it using bruteforce, i generate all non repeated 9 length number combinations using a recursive algorithm. It does it pretty fast. Up to here all is great! But the problem is when my program operates depending the character on the blocks. Its extremely slow (it never gets the answer), because of the chars comparation against +, -, *, etc. Im doing a CASE. Is there some way or some programming language wich allows dinamic creation of operators? So i can define the operator ROW1COL2 to be a +, and the same way to all other operations. I leave a screenshot of the app, so its easier to understand how the puzzle works. http://www.imageshare.web.id/images/9gg5cev8vyokp8rhlot9.png PD: The algorithm works, i tryed it with a trivial puzzle, and solved it in a second.

    Read the article

  • Issues loading SWF with External SWF Files - using SWFObject and ExternalInterface

    - by wdense51
    I'm having issues with loading a SWF that references external SWF files... The main SWF loads fine if the HTML file is in the same folder as all the SWFs using the following code: <script type="text/javascript" src="../js/swfobject.js"></script> <script type="text/javascript"> var flashvars = {}; var params = { allowScriptAccess: "always" }; params.quality = "high"; params.wmode = "transparent"; var attributes = {id:"IDofSWF", name:"IDofSWF"}; swfobject.embedSWF("event_so_js.swf", "flashContent", "700", "400", "7.0.0", false, flashvars, params, attributes);</script> </head> <body> <div id="flashContent"> <object data="event_so_js.swf" name="IDofSWF" id="IDofSWF" type="application/x-shockwave-flash" width="700" height="400"></object></div> But as soon as I move the HTML file out of that folder to the root folder and update the links, it doesn't load correctly - it seems that it's having trouble with the external SWF files. I did have it successfully load one of the external SWF files directly, but it's having trouble with the main SWF. All of the SWF files are in the same folder, so I don't know why it's having issues. Here's the code for the HTML file when it's in the root folder: <script type="text/javascript" src="js/swfobject.js"></script> <script type="text/javascript"> var flashvars = {}; var params = { allowScriptAccess: "always" }; params.quality = "high"; params.wmode = "transparent"; var attributes = {id:"IDofSWF", name:"IDofSWF"}; swfobject.embedSWF("folio/event_so_js.swf", "flashContent", "700", "400", "9.0.0", false, flashvars, params, attributes);</script> </head> <body> <div id="flashContent"> <object data="folio/event_so_js.swf" name="IDofSWF" id="IDofSWF" type="application/x-shockwave-flash" width="700" height="400"></object></div> There is also a link on the page that calls a function in the actionscript using ExternalInterface, so it could be that causing the issues. The code for the link is: <a href="#" onclick="document.getElementById('IDofSWF').clicky()"> Any help would be awesome, because it's really confusing me.

    Read the article

  • Boolean 'NOT' in T-SQL not working on 'bit' datatype?

    - by Joannes Vermorel
    Trying to perform a single boolean NOT operation, it appears that under MS SQL Server 2005, the following block does not work DECLARE @MyBoolean bit; SET @MyBoolean = 0; SET @MyBoolean = NOT @MyBoolean; SELECT @MyBoolean; Instead, I am getting more successful with DECLARE @MyBoolean bit; SET @MyBoolean = 0; SET @MyBoolean = 1 - @MyBoolean; SELECT @MyBoolean; Yet, this looks a bit a twisted way to express something as simple as a negation. Am I missing something?

    Read the article

  • Code to apply expression tree directly to List

    - by Gamma Vega
    Is there a method call in Linq that will apply a expression tree directly on a List<V>? For instance, if I have a expression tree that is built on Order type, and i have a collection of List<Order> items on which i need to apply this expression. I am looking something similar to: class OrderListStore : IQueryable<V>, <other interfaces required to implement custom linq provider> { List<Order> orders; public Expression Expression { get { return Expression.Constant(this); } } IEnumerator<V> IEnumerable<V>.GetEnumerator() { //Here I need to have a method that will take the existing expression //and directly apply on list something like this .. Expression.Translate(orders); } } Any help in this regard is highly appreciated.

    Read the article

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