Search Results

Search found 15316 results on 613 pages for 'coding style'.

Page 77/613 | < Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >

  • Html + Css: How to create a auto-resizing rotated background?

    - by Sebastian P.R. Gingter
    Hi, image a complete black web page. On this web page is a 100% size white div that fills the whole page. I'd like to rotate this div by -7 degrees (or 7 degrees counter-clock wise). This will result in the black background being visible in triangles on the edges, just like you had placed a piece of paper on a desk and turned it a bit to the left. Actually this can be done with some css and it's working quite well (except for IE). The real problem now is: I'd like to have a normal, non-rotated div element on top of that to display the content in, so that only the background is rotated. Rotating a contained div counterwise doesn't work though, because through the two transformations the text will be blurry in all browsers. How can I realize that? Best would be a solution workiing in current Webkit browsers, FF3.5+ and IE7+. If only IE8+ I could live with that too.

    Read the article

  • What goes into main function?

    - by Woltan
    I am looking for a best practice tip of what goes into the main function of a program using c++. Currently I think two approaches are possible. (Although the "margins" of those approaches can be arbitrarily close to each other) 1: Write a "Master"-class that receives the parameters passed to the main function and handle the complete program in that "Master"-class (Of course you also make use of other classes). Therefore the main function would be reduced to a minimum of lines. #include "MasterClass.h" int main(int args, char* argv[]) { MasterClass MC(args, argv); } 2: Write the "complete" program in the main function making use of user defined objects of course! However there are also global functions involved and the main function can get somewhat large. I am looking for some general guidelines of how to write the main function of a program in c++. I came across this issue by trying to write some unit test for the first approach, which is a little difficult since most of the methods are private. Thx in advance for any help, suggestion, link, ...

    Read the article

  • please help me to find Bug in my Code (segmentation fault)

    - by Vikramaditya Battina
    i am tring to solve this http://www.spoj.com/problems/LEXISORT/ question it working fine in visual studio compiler and IDEone also but when i running in SPOJ compiler it is getting SEGSIGV error Here my code goes #include<stdio.h> #include<stdlib.h> #include<string.h> char *getString(); void lexisort(char **str,int num); void countsort(char **str,int i,int num); int main() { int num_test; int num_strings; char **str; int i,j; scanf("%d",&num_test); for(i=0;i<num_test;i++) { scanf("%d",&num_strings); str=(char **)malloc(sizeof(char *)*num_strings); for(j=0;j<num_strings;j++) { str[j]=(char *)malloc(sizeof(char)*11); scanf("%s",str[j]); } lexisort(str,num_strings); for(j=0;j<num_strings;j++) { printf("%s\n",str[j]); free(str[j]); } free(str); } return 0; } void lexisort(char **str,int num) { int i; for(i=9;i>=0;i--) { countsort(str,i,num); } } void countsort(char **str,int i,int num) { int buff[52]={0,0},k,x; char **temp=(char **)malloc(sizeof(char *)*num); for(k=0;k<52;k++) { buff[k]=0; } for(k=0;k<num;k++) { if(str[k][i]>='A' && str[k][i]<='Z') { buff[(str[k][i]-'A')]++; } else { buff[26+(str[k][i]-'a')]++; } } for(k=1;k<52;k++) { buff[k]=buff[k]+buff[k-1]; } for(k=num-1;k>=0;k--) { if(str[k][i]>='A' && str[k][i]<='Z') { x=buff[(str[k][i]-'A')]; temp[x-1]=str[k]; buff[(str[k][i]-'A')]--; } else { x=buff[26+(str[k][i]-'a')]; temp[x-1]=str[k]; buff[26+(str[k][i]-'a')]--; } } for(k=0;k<num;k++) { str[k]=temp[k]; } free(temp); }

    Read the article

  • How to remove the shadow from a librarystack

    - by red-X
    I'm currently in a project where I need a LibraryStack with no visuals at all, so it would just show the content. If I just remove the background a shadow stays in view which I cant seem to remove... This code looks like: <s:LibraryStack Background="Transparent"> <s:LibraryStackItem Background="AliceBlue"/> <s:LibraryStackItem Background="Bisque"/> <s:LibraryStackItem Background="Salmon"/> </s:LibraryStack> This stack is just for explaining purposes, the actual stack is added in the code behind in c#. So preferably any answers that would be usefull to add in c#.

    Read the article

  • A good way to implement useable Callbacks in C++

    - by Marcel J.
    I have a custom Menu class written in C++. To seperate the code into easy-to-read functions I am using Callbacks. Since I don't want to use Singletons for the Host of the Menu I provide another parameter (target) which will be given to the callback as the first parameter (some kind of workaround for the missing "this" reference). Registration-Signature AddItem(string s, void(*callback)(void*,MenuItem*), void* target = NULL) Example of a Registration menu->AddItem(TRANSLATE, "translate", &MyApp::OnModeSelected); Example of a Handler /* static */ void MyApp::OnModeSelected(void* that, MenuItem* item) { MyApp *self = (MyApp*)that; self->activeMode = item->text; } Is there anything one could consider dirty with this approach? Are there maybe better ones?

    Read the article

  • Python Etiquette: Importing Modules

    - by F3AR3DLEGEND
    Say I have two Python modules: module1.py: import module2 def myFunct(): print "called from module1" module2.py: def myFunct(): print "called from module2" def someFunct(): print "also called from module2" If I import module1, is it better etiquette to re-import module2, or just refer to it as module1.module2? For example (someotherfile.py): import module1 module1.myFunct() # prints "called from module1" module1.module2.myFunct() # prints "called from module2" I can also do this: module2 = module1.module2. Now, I can directly call module2.myFunct(). However, I can change module1.py to: from module2 import * def myFunct(): print "called from module1" Now, in someotherfile.py, I can do this: import module1 module1.myFunct() # prints "called from module1"; overrides module2 module1.someFunct() # prints "also called from module2" Also, by importing *, help('module1') shows all of the functions from module2. On the other hand, (assuming module1.py uses import module2), I can do: someotherfile.py: import module1, module2 module1.myFunct() # prints "called from module1" module2.myFunct() # prints "called from module2" Again, which is better etiquette and practice? To import module2 again, or to just refer to module1's importation?

    Read the article

  • C#: Union of two ICollections? (equivlaent of Java's addAll())

    - by Rosarch
    I have two ICollections of which I would like to take the union. Currently, I'm doing this with a foreach loop, but that feels verbose and hideous. What is the C# equivalent of Java's addAll()? Example of this problem: ICollection<IDictionary<string, string>> result = new HashSet<IDictionary<string, string>>(); // ... ICollection<IDictionary<string, string>> fromSubTree = GetAllTypeWithin(elementName, element); foreach (IDictionary<string, string> dict in fromSubTree) // hacky { result.Add(dict); } // result is now the union of the two sets

    Read the article

  • Redundant code constructs

    - by Diomidis Spinellis
    The most egregiously redundant code construct I often see involves using the code sequence if (condition) return true; else return false; instead of simply writing return (condition); I've seen this beginner error in all sorts of languages: from Pascal and C to PHP and Java. What other such constructs would you flag in a code review?

    Read the article

  • Enum.TryParse with Flags attribute

    - by Sunny
    I have written code to TryParse enum either by value or by its name as shown below. How can I extend this code to include parsing enums with Flags attribute? public static bool TryParse<T>(this T enum_type, object value, out T result) where T : struct { return enum_type.TryParse<T>(value, true, out result); } public static bool TryParse<T>(this T enum_type, object value, bool ignoreCase, out T result) where T : struct { result = default(T); var is_converted = false; var is_valid_value_for_conversion = new Func<T, object, bool, bool>[]{ (e, v, i) => e.GetType().IsEnum, (e, v, i) => value != null, (e, v, i) => Enum.GetNames(e.GetType()).Any(n => String.Compare(n, v.ToString(), i) == 0) || Enum.IsDefined(e.GetType(), v) }; if(is_valid_value_for_conversion.All(rule => rule(enum_type, value, ignoreCase))){ result = (T)Enum.Parse(typeof(T), value.ToString(), ignoreCase); is_converted = true; } return is_converted; } Currently this code works for the following enums: enum SomeEnum{ A, B, C } // can parse either by 'A' or 'a' enum SomeEnum1 : int { A = 1, B = 2, C = 3 } // can parse either by 'A' or 'a' or 1 or "1" Does not work for: [Flags] enum SomeEnum2 { A = 1, B = 2, C = 4 } // can parse either by 'A' or 'a' // cannot parse for A|B Thanks!

    Read the article

  • C++ iterators & loop optimization

    - by Quantum7
    I see a lot of c++ code that looks like this: for( const_iterator it = list.begin(), const_iterator ite = list.end(); it != ite; ++it) As opposed to the more concise version: for( const_iterator it = list.begin(); it != list.end(); ++it) Will there be any difference in speed between these two conventions? Naively the first will be slightly faster since list.end() is only called once. But since the iterator is const, it seems like the compiler will pull this test out of the loop, generating equivalent assembly for both.

    Read the article

  • Should I use block identifiers ("end;") in my code?

    - by JosephStyons
    Code Complete says it is good practice to always use block identifiers, both for clarity and as a defensive measure. Since reading that book, I've been doing that religiously. Sometimes it seems excessive though, as in the case below. Is Steve McConnell right to insist on always using block identifiers? Which of these would you use? //naughty and brief with myGrid do for currRow := FixedRows to RowCount - 1 do if RowChanged(currRow) then if not(RecordExists(currRow)) then InsertNewRecord(currRow) else UpdateExistingRecord(currRow); //well behaved and verbose with myGrid do begin for currRow := FixedRows to RowCount - 1 do begin if RowChanged(currRow) then begin if not(RecordExists(currRow)) then begin InsertNewRecord(currRow); end //if it didn't exist, so insert it else begin UpdateExistingRecord(currRow); end; //else it existed, so update it end; //if any change end; //for each row in the grid end; //with myGrid

    Read the article

  • Examples of both beautiful and ugly java code?

    - by tputkonen
    I would like to demonstrate how difficult it is for a layman to identify high quality code from flawed code. I'm thinking of doing this with the help of two java methods. Both of the methods should look like they do the same, pretty simple thing. However one of them should have several kind of flaws, for example: iteration with array off by one error string concatenations causing lots of objects to be created (as opposed to StringBuffer in the "good" code, which looks more complicated) possibly null pointer exception (but it should not be trivial to spot) Those are just some examples, all kinds of other issues including bugs and performance related structures are highly appreciated. Methods should be around 10-20 lines of length, and the task they do should be something simple - preferably printing something in an iteration.

    Read the article

  • Is there a proper and wrong way to format CSS?

    - by DavidR
    When I first started writing CSS, I was writing it in an expanded form div.class { margin: 10px 5px 3px; border: 1px solid #333; font-weight: bold; } .class .subclass { text-align:right; } but now I find myself writing css like this: (Example from code I'm actually writing now) .object1 {} .scrollButton{width:44px;height:135px;} .scrollButton img {padding:51px 0 0 23px;} .object2 {width:165px;height:94px;margin:15px 0 0 23px;padding:15px 0 0 10px;background:#fff;} .featuredObject .symbol{line-height:30px; padding-top:6px;} .featuredObject .value {width:90px;} .featuredObject .valueChange {padding:5px 0 0 0;} .featuredObject img {position:absolute;margin:32px 0 0 107px;} and I'm beginning to worry because a lot of the time I see the first form done in examples online, while I find the second form a lot easier for me to work with. It has a lower vertical height, so I can see all the classes at a glance with less scrolling, the tabulation of the hierarchy seems more apparent, and it looks more like code I'd write with javascript or html. Is this a valid way of doing code, or to keep with standards when putting it online should I use the vertical form instead?

    Read the article

  • Acceptable to have spaces before dot?

    - by Rudy
    What is the general opinion on the 2nd indentation method below. // Normal indentation a.Value = "foobar"; ab.Checked = false; foo.Value = "foobar"; foobar.Checked = true; // Spaces before the dot to align the properties/methods a .Value = "foobar"; ab .Checked = false; foo .Value = "foobar"; foobar.Checked = true; This should probably be a wiki, but I either don't have enough privileges or don't know how to change it.

    Read the article

  • Should .net comments start with a capital letter and end with a period?

    - by Hamish Grubijan
    Depending on the feedback I get, I might raise this "standard" with my colleagues. This might become a custom StyleCop rule. is there one written already? So, Stylecop already dictates this for summary, param, and return documentation tags. Do you think it makes sense to demand the same from comments? On related note: if a comment is already long, then should it be written as a proper sentence? For example (perhaps I tried too hard to illustrate a bad comment): //if exception quit vs. // If an exception occurred, then quit. If figured - most of the time, if one bothers to write a comment, then it might as well be informative. Consider these two samples: //if exception quit if (exc != null) { Application.Exit(-1); } and // If an exception occurred, then quit. if (exc != null) { Application.Exit(-1); } Arguably, one does not need a comment at all, but since one is provided, I would think that the second one is better. Please back up your opinion. Do you have a good reference for the art of commenting, particularly if it relates to .Net? Thanks.

    Read the article

  • Purpose of IF, ELSE, FOR macros ?

    - by psihodelia
    I have a source code of a library which has a lot of strange IF, ELSE, FOR, etc. macros for all common C-keywords instead of using just usual if,else,for,while keywords. These macros are defined like this: #define IF( a) if( increment_if(), a) where increment_if() function is defined so: static __inline void increment_if( void) { // If the "IF" operator comes just after an "ELSE", its counter // must not be incremented. ... //implementation } I don't really understand, what is the purpose of such macros? This library is for a real-time application and I suppose that using such macros must slow-down an application.

    Read the article

  • Let and construct versus let in sequence

    - by Stringer
    Consider this OCaml code: let coupe_inter i j cases = let lcases = Array.length cases in let low,_,_ = cases.(i) and _,high,_ = cases.(j) in low,high, Array.sub cases i (j-i+1), case_append (Array.sub cases 0 i) (Array.sub cases (j+1) (lcases-(j+1))) Why the expression let ... and ... in is used in place of a let ... in let ... in sequence (like F# force you to do)? This construct seems quite frequent in OCaml code. Thanks!

    Read the article

  • Semantic #region usage

    - by Luca
    What's your opinion about using #region folding using application semantic, instead of folding for "syntax". For example: #region Application Loop #region User Management #region This Kinf of stuffs instead of #region Private Routines #region Public Properties #region ThisRoutine // (Yes, I've seen this also!) In this logic, I'm starting fold even routine bodies. I'm starting to love #region directive (even using #pragma region when using C++!).

    Read the article

  • How to use SQLiteOpenHelper without or less restrictive use of Context?

    - by Pentium10
    If you extend SQLiteOpenHelper, for the Constructor you have to use a Context. I am wondering if there is a way to leave this out, and be able to work with database tables without a Context. Or at least be least restrictive, I mean a way of project/class structure that will make history the several context passings I have to do now. As it is my application has several level of classes, chained in each other, and there are a few that connects to the database, but have no whatsoever influence on the interface, so they don't actually need the Context. Are you creating your classes in the way that you pass each time a Context to them? If not, how you do, how you reuse a Context in a short class?

    Read the article

< Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >