Search Results

Search found 6502 results on 261 pages for 'dont reinvent the wheel'.

Page 53/261 | < Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >

  • What are some C++ Standard Library usage best practices?

    - by apphacker
    I'm learning C++ and the book I'm reading (The C++ Programming Language) says to not reinvent the wheel, to rely on the standard libraries. In C, I often end up creating a linked list, and link list iteration over and over again (maybe I'm doing that wrong not sure), so the ideas of containers available in C++, and strings, and algorithms really appeal to me. However I have read a little online, and heard some criticisms from my friends and coworkers about STL, so I thought I maybe I'd pick some brains here. What are some best practices for using STL, and what lessons have you learned about STL?

    Read the article

  • LLBLGen and the repository pattern

    - by user137348
    I was wondering if building a repository on the top LLBLGen (adapter) is a good idea. I don't want to overengineer and reinvent the wheel again. The DataAccessAdapter class could be some kind of a generic repository.It has all the CRUD methods you need. But on the other side for a larger project it could be good to have a layer between your ORM and service layer. I'd like to hear your opinions, if your using the repository pattern with LLBLGen,if yes why if no why not. If you have some implementation, post it please.

    Read the article

  • Creating standalone, console (shell) for domain-specific operations

    - by mr.b
    Say that I have a system service, and I want to offer a low-level maintenance access to it. For that purpose, I'd like to create a standalone, console application that somehow connects to server process and lets user type in commands, allow it to use auto-completion and auto-suggestion on single/double TAB press (just like linux bash shell, mysql cli, cmd.exe, and countless others), allow command line editing capabilities (history, cursor keys to move around text..), etc. Now, it's not that much of a problem to create something like that by rolling my own from scratch, handling user input, scanning pressed keys, and doing correct actions. But, why reinvent the wheel? Is there some library/framework that helps with this kind of problems, just like readline library that offers improved command-line editing capabilities under linux? Of course, this new "shell" would respond only to valid, domain-specific commands, and would suggest valid arguments, options, switches... Any ideas? Thanks!

    Read the article

  • How do I enable mod_deflate for PHP files?

    - by DM.
    I have a Liquid Web VPS account, I've made sure that mod_deflate is installed and running/active. I used to gzip my css and js files via PHP, as well as my PHP files themselves... However, I'm now trying to do this via mod_deflate, and it seems to work fine for all files except for PHP files. (Txt files work fine, css, js, static HTML files, just nothing that is generated via a PHP file.) How do I fix this? (I used the "Compress all content" option under "Optimize Website" in cPanel, which creates an .htaccess file in the home directory (not public_html, one level higher than that) with exactly the same text as the "compress everything except images" example on http://httpd.apache.org/docs/2.0/mod/mod_deflate.html) .htaccess file: <IfModule mod_deflate.c> SetOutputFilter DEFLATE <IfModule mod_setenvif.c> # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 # the above regex won't work. You can use the following # workaround to get the desired effect: BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary </IfModule> <IfModule mod_headers.c> # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule>

    Read the article

  • Can Tomcat provide seperate (or HTTPS only) sessions for HTTPS requests?

    - by Joe
    I have a web application which contains both secure (SSL) and non-secure pages. A user can login to the site and must appear logged-in in both the SSL and non-SSL areas. (NB. SSL isn't implemented via Tomcat, but via Apache HTTPD servers which sit in front of Tomcat - so Tomcat has no SSL configuration.) The logged-in state is currently maintained via a servlet session (using Tomcat's vanilla session management). The obvious issue with this approach is that the JSESSIONID cookie is transported over both HTTP and HTTPS connections, meaning that it's potentially possible to intercept it and hijack the session. Are there any solutions to this without rolling our own session management (i.e. does Tomcat cater for this situation)? I'm prepared to implement our own session management, but don't want to reinvent something that may already be supported.

    Read the article

  • Business Objects Web Intelligence-style reporting in a Winform app. Is this possible?

    - by George
    I have a WinForm app that displays results in a Gridview control. If a user right mouse clicks on a row, he can then, from a popup menu, select a command to perform on the row much like windows File Explorer. But now I want to be able to give the user the ability to construct a filter so that he can control which rows are displayed in the grid w/o effecting the functionality of the application. I would also like the user to be able to select the columns/fields that he sees in the grid. For the basis of this question, let's assume that the data displayed in grid comes from a single table. business Objects' Web Intelligence and Desktop Intelligence applications give me very flexible and powerful reporting capabilities, but I want to integrate this capability into my WinForm application. Does Business Objects, or maybe Crystal Reports provide this sort of functionality? I can construct my own query builder but I'd rather not reinvent sliced bread.

    Read the article

  • Ajax request (from .NET) give me unexpected results

    - by ironnailpiercethesky
    I wanted to learn a little more about web and .NET so i decided to write a program to download binaries, webpages and does a little ajax. The first download site i tried was too easy. So i went against uploading.com. It seemed good, no captcha, some ajax use required, you cant guess all the data, it was perfect. After 2hours of messing around i got frustrated. For the life of me i could not get the ajax response to give me what i was expecting. I decided to use tamper data clear my cookies, click on the entry for the ajax request. Copy the Referer, cookies and postdata and came up with this code. It does not work! I am shocked that copying those fields did not work. I even tried setting the user agent (not in code linked) and it still did not work. Why isnt this POST on the ajax request not giving me the correct file? I notice the JsHttpRequest=12719132559480-xml changes based on time so if you want to run the code you should grab a new snapshot with tamperdata (or at least update that url). I dont see any extra headers in tamper data so does anyone know why i might not be getting the response expected? I know disabling cookies or javascript will make the link 'expired' automatically. I dont think javascript will matter because i got the data from tamperdata at the moment of request so what gives? What am i forgetting or what data am i not submitting properly?

    Read the article

  • Android Cursor strange behaviour

    - by sandis
    After many houres of bug searching in a big app, I have finally tracked down the bug. This logging captures the problem: Log.d(TAG,"buildList, DBresult.getInt(1): "+DBresult.getInt(1)); Log.d(TAG,"buildList, DBresult.getString(1): "+DBresult.getString(1)); Log.d(TAG,"buildList, DBresult.getInt(4): "+DBresult.getInt(4)); Log.d(TAG,"buildList, DBresult.getString(4): "+DBresult.getString(4)); The resulting output: 05-06 11:11:20.123: DEBUG/TodoList(18943): buildList, DBresult.getInt(1): 0 05-06 11:11:20.123: DEBUG/TodoList(18943): buildList, DBresult.getString(1): false 05-06 11:11:20.123: DEBUG/TodoList(18943): buildList, DBresult.getInt(4): 0 05-06 11:11:20.123: DEBUG/TodoList(18943): buildList, DBresult.getString(4): true There are no backgroung threads running. As you can see the problem is that '0' is interpreted as false on one occasion, and as true on another. Since I am completely lost on how this can happen, I dont know how to proceed. What could possibly result in such a behaviour? Both the columns are of the type "boolean", i.e a numeric in sqlite. Unfortunately the string returned is the correct value, while the integer is always 0. If I export the database to my computer and check it with SQlite Administrator I can see that the values are correctly set, it is only the getInt()-function that always returns 0. I know for a fact that this works in other apps I have coded, and I dont know why this has stopped working. I have tried compiling the code under 2.0, 2.0.1 and 2.1, and it always appears. I can make my app runnable again by getting boolean values like this: myBool= (DBresult.getString(0).equals("true")); but that is both ugly and not optimized. Any suggestions on what is causing this behaviour is welcome. Cheers,

    Read the article

  • Open a dialog box in same window on selectOneMenu change

    - by Pravingate
    I have a jsf page where I have a selectOneMenu and , I want to open a dialog box on selectOneMenu changes. As a example if user selects a value ="passive" from jsf selectOneMenu it should open a dialog box or a light box on same page where I want to display a small jsf form like as here done. http://www.primefaces.org/showcase-labs/ui/dialogLogin.jsf and I also want save that submitted data in my backing bean somewhere so I can store it in to database later. I dont know how to open a dialog box or light box from backing bean in same window,as we will identify value change using valueChangeListener event or by using ajax event. I am able to identify which value is selected from selectOneMenu(DropdownMenu), but dont know how to open a dialog box on selecting particular value. <h:outputLabel value="* Country: "/> <h:selectOneMenu id="someSelect" value="#{testController.countryName}" required="true"> <f:selectItem itemLabel="Select Country" itemValue=""/> <f:selectItems value="#{testController.countryNamesSelectItems}"/> </h:selectOneMenu> Supoose we have 2 options in selectItems as India and Austrlia, then If a user choose India a dialog box should open on same page where a user need to fill some information and need to submit if he is from india (like here in example http://www.primefaces.org/showcase-labs/ui/dialogLogin.jsf user will put his username and password and submits data) Hope this helps How can I achieve that by using jsf or javascript or ajax or by any else way?

    Read the article

  • A B+tree simple implementation in C

    - by initpy
    Hi guys, I'm working on a fun project where I need a simple key/value store that uses B+Trees. I studied them some years ago, and to be honest, I don't want to reinvent the wheel, so I'm looking for a simple implementation in C of b+tree that I can just include in my project. I know of sqlite's, dbm's and tokyocabinet's ones but they're a little too "complicated" for my needs. Is there any (even pedagogical) work on this you can refer me to? Do you have some code to share? Thanks a lot!

    Read the article

  • Can someone tell me why I'm seg faulting in this simple C program?

    - by user299648
    I keep on getting seg faulted, and for the life of me I dont why. The file I'm scanning is just 18 strings in 18 lines. I thinks the problem is the way I'm mallocing the double pointer called picks, but I dont know exactly why. I'm am only trying to scanf strings that are less than 15 chars long, so I don't see the problem. Can someone please help. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LENGTH 100 int main( int argc,char *argv[] ) { char* string = malloc( sizeof(char) ); char** picks = malloc(15*sizeof(char)); FILE* pick_file = fopen( argv[l], "r" ); int num_picks; for( num_picks=0 ; fgets( string, MAX_LENGTH, pick_file ) != NULL ; num_picks++ ) { printf("pick a/an %s ", string ); scanf( "%s", picks+num_picks ); } int x; for(x=0; x<num_picks;x++) printf("s\n", picks+x); }

    Read the article

  • Interface that Entails the Implementation of Indexer

    - by Ngu Soon Hui
    I am looking for a framework-defined interface that declares indexer. In other words, I am looking for something like this: public interface IYourList<T> { T this[int index] { get; set; } } I just wonder whether .Net framework contains such interface? If yes, what is it called? You might ask why I can't just create the interface myself. Well, I could have. But if .Net framework already has that why should I reinvent the wheel?

    Read the article

  • Entity Sql Group By problem, please help

    - by Zviadi
    Hello, help me please with this simple E-sql query: var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)"; heres what I have. I have simple Entity called OrdersIncomes with ID,PaidMoney,DatePaid,Order_ID properties I want to select Month and Summed PaidMoney like this: month Paidmoney 1 500 2 700 3 1200 T-SQL looks like this and works fine: select MONTH(o.DatePaid), SUM(o.PaidMoney) from OrdersIncomes as o group by MONTH(o.DatePaid) results: 3 31.0000 4 127.0000 5 20.0000 (3 row(s) affected) but E-SQL doesnot work and I dont know what to do. here my E-SQL which needs refactoring: var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)"; theres exception: ErrorDescription = "The identifier 'o' is not valid because it is not contained either in an aggregate function or in the GROUP BY clause." if I include o in group by clause, like: FROM XACCModel.OrdersIncomes as o group by o then I dont get summed and agregated results. is this some bug? or what Im doing wrong. heres Linq to Entities query and it works too: var incomeResult = from ic in _context.OrdersIncomes group ic by ic.DatePaid.Month into gr select new { Month = gr.Key, PaidMoney = gr.Sum(i = i.PaidMoney) };

    Read the article

  • How to parse a Zend URL for parameters?

    - by wizzard
    I am trying to extract the GET parameters from a ZF REST URL. It's not the current request and I don't want to call the URL or execute the route, I just need the parameters. I'm looking for a utility function like parse_url(), but for the Zend REST format. Is there one, or do I have to reinvent the wheel? I've tried a few things like creating a new Zend_Controller_Request_Http but the parameters aren't being populated. It is a valid HTTP URL. Edit: Upon request, a sample Zend URL: http://localhost/index/index/param1/foo/param2/bar So I am just trying to get param1 and param2 out of this URL.

    Read the article

  • java: "downcasting" to new object / opposite of slicing

    - by rhavin
    Sorry, i really dont know how to make a headline for that question; maybe there is a name for what im trying to do that i dont know, but i can explain it with some code: Guess you have a class that unfortunately neither has a copy-constructor nor a public static copy method. class A { private int i; // <- private, cant access String x; // <- even worse: cant access unless in same pkg! /* … other stuff, ctor, etc. … */ public A clone() { A a = new A(); a.i = i; a.x = x; return x; } } Guess further, there is some function that returns an object of that class: public static A someFn(x,y,z); Now the problem: I want to derive from that class to add some functionality. Unfortunately, i neither have a sizeof in java nor a cc or static copy method. So when i do a class B extends A { protected w; public B clone() { /* as usual */ } } then i can clone my B and get a new one, but how can i convert the returned A from someFn() into a B. Is there anyway to do the opposite of slicing in java? if i clone it, it's still an A, and i cant copy it field by field. This is all simple in c++, but how to do this in Java?

    Read the article

  • MYSQL JOIN WHERE ISSUES - need some kind of if condition

    - by Breezer
    Hi Well this will be hard to explain but ill do my best The thing is i have 4 tables all with a specific column to relate to eachother. 1 table with users(agent_users) , 1 with working hours(agent_pers), 1 with sold items(agent_stat),1 with project(agent_pro) the user and the project table is irrelevant in the issue at hand but to give you a better understanding why certain tables is included in my query i decided to still mention them =) The thing is that I use 2 pages to insert data to the working hour and the sold items during that time tables, then i have a third page to summarize everything for current month, the query for that is as following: SELECT *, SUM(sv_p_kom),SUM(sv_p_gick),SUM(sv_p_lunch) FROM (( agent_users LEFT JOIN agent_pers ON agent_users.sv_aid = agent_pers.sv_p_uid) LEFT JOIN agent_stat ON agent_pers.sv_p_uid = agent_stat.sv_s_uid) LEFT JOIN agent_pro ON agent_pers.sv_p_pid=agent_pro.p_id WHERE MONTH(agent_pers.sv_p_datum) =7 GROUP BY sv_aname so the problem is now that i dont want sold items from previous months to get included in the data received, i know i could solve that by simple adding in the WHERE part MONTH(agent_stat.sv_s_datum) =7 but then if no items been sold that month no data at all will show up not the time or anything. Any aid on how i could solve this is greatly appreciated. if there's something that's not so clear dont hesitate to ask and ill try my best to answer. after all my english isn't the best out there :P regards breezer

    Read the article

  • CSS-Friendly Menu adapter that emits the same markup as .NET 4.0

    - by Joe
    For .NET 2.x/3.x there exists a CSS-Friendly Adapter on CodePlex that emits markup for an ASP.NET Menu Control as an ul. The .NET 4.0 Menu control will also emit an ul, but the CSS class names are different from those emitted by the CSS-Friendly Adapter 1.0 on CodePlex. In the interests of having a single version of CSS for .NET 2/3/4 sites, I want to create a version of the CSS-Friendly menu adapter that emits the same markup as the .NET 4.0 Menu control. Before doing so, I thought I'd ask here to see if it's already been done, so I don't reinvent the wheel. Anyone?

    Read the article

  • MAAttachedWindow hide

    - by Montecorte
    I had the same problem that The-Kenny at this post but I fixed it adding the windowDidResignKey: method on the MAAttachedWindow.m, but now my problem is that when I click outside the StatusBar item keeps blue background and when I click another time on the status item it goes normally and I have to click a second time on it to show the window. I tried to add a method in the CustomView (the view of the status item) that do the same thing that te mouseDown method: - (void)mouseDown:(NSEvent *)event { NSRect frame = [[self window] frame]; NSPoint pt = NSMakePoint(NSMidX(frame), NSMidY(frame)); NSLog(@"%g,%g",pt.x,pt.y); clicked = !clicked; [controller toggleAttachedWindowAtPoint:pt]; [self setNeedsDisplay:YES];} my method is: - (void)windowDidResignKey { NSLog(@"Resigned"); NSRect frame = [[self window] frame]; NSPoint pt = NSMakePoint(NSMidX(frame), NSMidY(frame)); NSLog(@"%g,%g",pt.x,pt.y); clicked = !clicked; [controller toggleAttachedWindowAtPoint:pt]; [self setNeedsDisplay:YES];} I call this method in the windowDidResignKey that I have defined on MAAttachedWindow.m, but this method dont call correctly the toggleAttachedWindowAtPoint method, I dont know exactly why, it's only called when I click another time over the status item If anybody knows how to do that any help would be fine. Thank you so much :)

    Read the article

  • ready to use design pattern APIs for PHP?

    - by ajsie
    i know that in Java you can use their built-in APIs for design pattern. eg. if you want to use the observer pattern, you just have to extend your Subject class with the Observable class. is this possible for PHP? are there any libraries for the design patterns ready to use. in this way you don't have to reinvent the wheel and you also let many developers follow a standard. does Zend library have these API:s?

    Read the article

  • Is there a module that implements an efficient array type in Erlang?

    - by dsmith
    I have been looking for an array type with the following characteristics in Erlang. append(vector(), term()) O(1) nth(Idx, vector()) O(1) set(Idx, vector(), term()) O(1) insert(Idx, vector(), term()) O(N) remove(Idx, vector()) O(N) I normally use a tuple for this purpose, but the performance characteristics are not what I would want for large N. My testing shows the following performance characteristics... erlang:append_element/2 O(N). erlang:setelement/3 O(N). I have started on a module based on the clojure.lang.PersistentVector implementation, but if it's already been done I won't reinvent the wheel.

    Read the article

  • Voice Control iOS

    - by Marc Tanis
    I would like to build a simple reader app for the iPad 2 that would allow users to navigate/read via voice controls. The app would allow the user to enter a mode where the microphone was live and listened for predefined keywords like 'down', 'up', 'next', 'back', 'home', etc. I don't want to reinvent the wheel on this so I'm just wondering first, if someone has done this already and if not, are there any good tutorials or SDKs available to help with recording someone's voice, and then comparing future output to see if it matches, or just dealing with the microphone in general?

    Read the article

  • NSMutableArray memory management

    - by chicken
    NSMutableArray *a1 = [[NSMutableArray alloc] init]; NSMutableArray *a2 = [NSMutableArray array]; TempObj *obj = [[TempObj alloc] init]; //assume this line is repeated for each obj [a1 addObject:obj]; [a1 addObject:obj2]; [a1 addObject:obj3]; [a1 addObject:obj4]; [obj release]; [obj2 release]; [obj3 release]; [obj4 release]; [a1 release]; Ok so a2 is an autorelease obj so i dont have to call release on it? Also how do you know when you get an autorelease object? And for a1, i dont have to loop through the array and release each object first? What if i called [a1 removeAllObjects]; does that call [[a1 objectAtIndex:#] release]; Am i supposed to release those objects after ive added them to the array?

    Read the article

  • Structure's with strings and input

    - by Beginnernato
    so i have the following structure and function that add's things to the function - struct scoreentry_node { struct scoreentry_node *next; int score; char* name; } ; typedef struct scoreentry_node *score_entry; score_entry add(int in, char* n, score_entry en) { score_entry r = malloc(sizeof(struct scoreentry_node)); r->score = in; r->name = n; r->next = en; return r; } i have input that take it in the following main file: int score; char name[]; int main(void) { score_entry readin = NULL; while(1) { scanf("%s%d", name, &score); readin = add(score, name, readin); // blah blah I dont know why but when input a name it gets added to readin, but when i input another name all the name's in readin have this new name for example: input: bob 10 readin = 10 bob NULL jill 20 readin = 20 jill 10 jill NULL I dont know why bob disappear's... any reason why it does that ?

    Read the article

  • Compute column widths in a HTML-like manner (based on cell contents)

    - by cipak
    Hi, I have a grid of data that I want to export to RTF, PDF etc. using various (and not perfect) PHP converters/generators. What I am missing most is the HTML table automatic adjustment of column widths based on the lengths of strings in the cells (strings contain line breaks which complicate things a bit, as they should be preserved). I need an algorithm that, given the contents of the cells (plain text), a total width of the table and an average width of a character, would return a width for each column. I wouldn't want to reinvent the wheel if something is already available. Of course it can't be perfect if the font is variable width, but an approximation would do just fine. Or maybe it could have a configurable table with widths for each character. Any hint would be appreciated. Thank you.

    Read the article

  • How to work with CTE. There is some error related to anchor.

    - by Shantanu Gupta
    I am creating a hierarchy representaion of a column. But an error occurs Details are Msg 240, Level 16, State 1, Line 1 Types don't match between the anchor and the recursive part in column "DISPLAY" of recursive query "CTE". I know there is some typecasting error. But I dont know how to remove error. Please just dont only sort out my error. I need explanation why this error is coming. When this error occurs. I am trying to sort table on the basis of sort col that i m introducing. I want to add '-' at every level and want to sort accordingly. Please help WITH CTE (PK_CATEGORY_ID, [DESCRIPTION], FK_CATEGORY_ID, DISPLAY, SORT, DEPTH) AS ( SELECT PK_CATEGORY_ID, [DESCRIPTION], FK_CATEGORY_ID, '-' AS DISPLAY, '--' AS SORT, 0 AS DEPTH FROM dbo.L_CATEGORY_TYPE WHERE FK_CATEGORY_ID IS NULL UNION ALL SELECT T.PK_CATEGORY_ID, T.[DESCRIPTION], T.FK_CATEGORY_ID, CAST(DISPLAY+T.[DESCRIPTION] AS VARCHAR(1000)), '--' AS SORT, C.DEPTH +1 FROM dbo.L_CATEGORY_TYPE T JOIN CTE C ON C.PK_CATEGORY_ID = T.FK_CATEGORY_ID --SELECT T.PK_CATEGORY_ID, C.SORT+T.[DESCRIPTION], T.FK_CATEGORY_ID --, CAST('--' + C.SORT AS VARCHAR(1000)) AS SORT, CAST(DEPTH +1 AS INT) AS DEPTH --FROM dbo.L_CATEGORY_TYPE T JOIN CTE C ON C.FK_CATEGORY_ID = T.PK_CATEGORY_ID ) SELECT PK_CATEGORY_ID, [DESCRIPTION], FK_CATEGORY_ID, DISPLAY, SORT, DEPTH FROM CTE ORDER BY SORT

    Read the article

< Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >