Search Results

Search found 15210 results on 609 pages for 'technical writing'.

Page 149/609 | < Previous Page | 145 146 147 148 149 150 151 152 153 154 155 156  | Next Page >

  • Do I lose the benefits of macro recording if I develop Excel apps in Visual Studio?

    - by DanM
    I've written lots of Excel macros in the past using the following development process: Record a macro. Open the VBA editor. Edit the macro. I'm now experimenting with a Visual Studio 2008 "Excel 2007 Add-In" project (C#), and I'm wondering if I will have to give up this development process. Questions: I know I can still record macros using Excel, but is there any way to access the resulting code in Visual Studio? Or do I just have to copy and paste then C#-ize it? What happens with my "Personal Macro Workbook"? Can I use the macros I have stored in there within C#? Or is there some way to convert them to C#? If there is some support for opening and editing VBA macros in Visual Studio, can you provide a very brief summary of how it works or point me to a good reference? Do you have any other tips for transitioning from writing macros in VBA using Excel's built-in editor to writing them in C# with Visual Studio?

    Read the article

  • unbuffered I/O in Linux

    - by stuck
    I'm writing lots and lots of data that will not be read again for weeks - as my program runs the amount of free memory on the machine (displayed with 'free' or 'top') drops very quickly, the amount of memory my app uses does not increase - neither does the amount of memory used by other processes. This leads me to believe the memory is being consumed by the filesystems cache - since I do not intend to read this data for a long time I'm hoping to bypass the systems buffers, such that my data is written directly to disk. I dont have dreams of improving perf or being a super ninja, my hope is to give a hint to the filesystem that I'm not going to be coming back for this memory any time soon, so dont spend time optimizing for those cases. On Windows I've faced similar problems and fixed the problem using FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH - the machines memory was not consumed by my app and the machine was more usable in general. I'm hoping to duplicate the improvements I've seen but on Linux. On Windows there is the restriction of writing in sector sized pieces, I'm happy with this restriction for the amount of gain I've measured. is there a similar way to do this in Linux?

    Read the article

  • Rails RESTful routs without #new, rspec trouble

    - by pdkl95
    I'm currently writing a Rails app, and hit a somewhat strange quirk. I have a controller PermissionsController, which is mainly for display purposes at the moment. So my routing is locked down: map.resources :permissions, :only => [:index, :show] Unfortunately, when writing the tests, one of the routing tests fails: it "does not recognize #new" do { :get => "/permissions/new" }.should_not be_routable end with the error: Expected 'GET /permissions/new' to fail, but it routed to {"action"=>"show", "id"=>"new", "controller"=>"permissions"} instead Obviously, the #show action's route is matching with /permissions/:id, which also gives the expected error Couldn't find Permission with ID=new if you actually browse to that URL. This is not a serious error, as it is correctly raising an exception with the bad :id parameter, but it's kind of ugly. Is there any way to actually make Rails reject that route? Some trick in the routing options that I'm missing? I suppose I should just leave that test out and ignore it, or maybe remove the whole RESTful idea altogether and go back to a simpler map.connect 'permissions/:id' style. I strongly suspect I'll be expanding this in the future, though, and kind of wanted to keep my controllers consistent with each other. Just having to add occasional :only or :except rules made routes.rb nice and clean...

    Read the article

  • User submitted content filtering

    - by Jim
    Hey all, Does anyone have any ideas on what could be used as a way to filter untrustworthy user submitted content? Take Yelp for instance, they would need to prevent competitors writing business reviews on their competitors. They would need to prevent business owners favourably reviewing their own business, or forcing friends/family to do so. They would need to prevent poor quality reviews from affecting a businesses rating and so on. I can't think what they might use to do this: Prevent multiple users from the same IP reviewing certain things Prevent business owners reviewing their own business (maybe even other businesses in the same categories as their own?) Somehow determine what a review is about and what the actual intentions behind it are Other than the first and second points, I can't think of any clever/easy way to filter potentially harmful reviews from being made available, other than a human doing it. Obviously for a site the size of Yelp this wouldn't be feasible, so what parameters could they take into consideration? Even with human intervention, how would anyone know it was the owners best buddy writing a fake review without knowing the people? I'm using this as an example in a larger study on the subject of filtering user content automatically. Does anyone have any ideas how these systems may work and what they take into consideration? Thanks!

    Read the article

  • Change class of parent div if radio input checked

    - by xxstevenxo
    I've been searching and searching google for answers to my question but have been unsuccessful so far. I'm hoping one of you guys could give me some assistance. I have 10 divs with the class name "dividend" holding a table with the classname/id of "container" then two smaller tables inside that. Within the container table at the bottom is a hidden radio button with the name "page1". I wrote an onClcick for the container table so the user can select the whole table instead of the radio button, but not I'm trying to change the style of the selected container so the users know they have selected it. I have tried a few different methods and I'm able to change the style to the new class by just writing document.getElementById('container').className = 'selected'; But because all 10 divs share the same name it will only change the style of the first element it finds. So I tried writing this loop to check if there are any selected radios in the document then to change the else name the style as the default. I'm sure its something stupid but I'm pretty stumped atm.. Any help would be appreciated. Thanks. selected = function () { var divs = document.getElementByTagName('DIV'), div, tbl, rad, stat, i; for (i = 0; i < divs.length; i++) { div = divs.id; if (div == 'dividend') { tbl = div.getElementById('container'); rad = tbl.getElementByTagName('INPUT'); if (rad.checked = true) { tbl.className = 'selected'; } } } };

    Read the article

  • Are reads and (transactional) writes faster for entities of the same group than otherwise?

    - by indiehacker
    What advantage is there to designing child-parent relationships, which allow us to do writes in transactions, when there is never a real concern for consistency and contention and those sort of more complex issues? Does it make writes and reads faster? Consider my situation where there are many .png images that are referenced to one mosaic layer, and these .png images are written just once by a single user. The user can design many mosaic layers and her mosaic layers and referenced image entities are never changed/updated, they are just deleted some time in the future. Other users can come to the web project site and interactively view the mosaic layer as different layouts/configurations of the images as they play (query) with different criteria. So reads should be very fast. So there is no real worry of contention, or users conflicting with one another with writing new image entities. And because of that I am assuming there is no "requirement" for the .png image entities to be grouped by their same mosaic layer in child-parent relationship. However, perhaps, since the documentation says they are stored close to one another, if the many image entities were grouped as children to a single mosaic layer parent than this has the advantage that the writing (in transaction) and reading will happen much faster?

    Read the article

  • Could I return a FileStream as a generic interface to a file?

    - by Eric
    I'm writing a class interface that needs to return references to binary files. Typically I would provide a reference to a file as a file path. However, I'm considering storing some of the files (such as a small thumbnail) in a database directly rather then on a file system. In this case I don't want to add the extra step of reading the thumbnail out of the database onto the disc and then returning a path to the file for my program to read. I'd want to stream the image directly out of the database into my program and avoid writing anything to the disc unless the user explicit wants to save something. Would having my interface return a FileStreamor even a Imagemake sense? Then it would be up to the implementing class to determine if the source of the FileStream or Image is a file on a disc or binary data in a database. public interface MyInterface { string Thumbnail {get;} string Attachment {get;} } vs public interface MyInterface { Image Thumbnail {get;} FileStream Attachment {get;} }

    Read the article

  • How to debug python del self.callbacks[s][cid] keyError when the error message does not indicate where in my code the error is

    - by lkloh
    In a python program I am writing, I get an error saying Traceback (most recent call last): File "/Applications/Canopy.app/appdata/canopy-1.4.0.1938.macosx- x86_64/Canopy.app/Contents/lib/python2.7/lib-tk/Tkinter.py", line 1470, in __call__ return self.func(*args) File "/Users/lkloh/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 413, in button_release_event FigureCanvasBase.button_release_event(self, x, y, num, guiEvent=event) File "/Users/lkloh/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1808, in button_release_event self.callbacks.process(s, event) File "/Users/lkloh/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/cbook.py", line 525, in process del self.callbacks[s][cid] KeyError: 103 Do you have any idea how I can debug this/ what could be wrong? The error message does not point to anywhere in code I have personally written. I get the error message only after I close my GUI window, but I want to fix it even though it does not break the functionality of my code. The error is part of a very big program I am writing, so I cannot post all my code, but below is code I think is relevant: def save(self, event): self.getSaveAxes() self.save_connect() def getSaveAxes(self): saveFigure = figure(figsize=(8,1)) saveFigure.clf() # size of save buttons rect_saveHeaders = [0.04,0.2,0.2,0.6] rect_saveHeadersFilterParams = [0.28,0.2,0.2,0.6] rect_saveHeadersOverride = [0.52,0.2,0.2,0.6] rect_saveQuit = [0.76,0.2,0.2,0.6] #initalize axes saveAxs = {} saveAxs['saveHeaders'] = saveFigure.add_axes(rect_saveHeaders) saveAxs['saveHeadersFilterParams'] = saveFigure.add_axes(rect_saveHeadersFilterParams) saveAxs['saveHeadersOverride'] = saveFigure.add_axes(rect_saveHeadersOverride) saveAxs['saveQuit'] = saveFigure.add_axes(rect_saveQuit) self.saveAxs = saveAxs self.save_connect() self.saveFigure = saveFigure show() def save_connect(self): #set buttons self.bn_saveHeaders = Button(self.saveAxs['saveHeaders'], 'Save\nHeaders\nOnly') self.bn_saveHeadersFilterParams = Button(self.saveAxs['saveHeadersFilterParams'], 'Save Headers &\n Filter Parameters') self.bn_saveHeadersOverride = Button(self.saveAxs['saveHeadersOverride'], 'Save Headers &\nOverride Data') self.bn_saveQuit = Button(self.saveAxs['saveQuit'], 'Quit') #connect buttons to functions they trigger self.cid_saveHeaders = self.bn_saveHeaders.on_clicked(self.save_headers) self.cid_savedHeadersFilterParams = self.bn_saveHeadersFilterParams.on_clicked(self.save_headers_filterParams) self.cid_saveHeadersOverride = self.bn_saveHeadersOverride.on_clicked(self.save_headers_override) self.cid_saveQuit = self.bn_saveQuit.on_clicked(self.save_quit) def save_quit(self, event): self.save_disconnect() close()

    Read the article

  • How can I programmatically determine if my workstation is locked?

    - by AgentConundrum
    I'm writing up some productivity/metrics tools for myself to help monitor my focus throughout the day. Recently, I've noticed that I tend to get off track more than usual and feel the need to get up and go for walks/drinks/etc and I'm concerned that I'm "wasting" too much time. Since I always lock my computer when I go anywhere, and I unlock it as soon as I return (even if I'm just reading at my desk, etc), I was wondering how I can determine, in code, how long the machine is locked. I'm writing this in C# if that helps, but I'm open to other ideas. I like the windows service idea (and have accepted it) for simplicity and cleanliness, but unfortunately I don't think it will work for me in this particular case. I wanted to run this on my workstation at work rather than home (or in addition to home, I suppose), but it's locked down pretty hard courtesy of the DoD. That's part of the reason I'm rolling my own, actually. I'll write it up anyway and see if it works. Thanks everyone!

    Read the article

  • Why do you program? Why do you do what you do? [closed]

    - by Pirate for Profit
    To me, writing a new program is like a puzzle. Before you write any code for a large system, you have to carefully craft each piece in your mind and imagine how all the pieces will fit together. If you don't, your solution may end up being undefined. What I mean is, I often don't know what I'm doing so I'll come to this site and beg for a code snippet, and then somehow try to hack it into my projects. I started writing GW-Basic when I was around 8 years old. Then it progressed from there, went to california university and did some Python and C++, but really didn't learn anything(college = highsk00l++). I've mostly been self-taught, took awhile to break bad habits and I'd say only in recent years would I consider myself understanding of design patterns and all that stuff (no but honestly procedural dudes, I would not want to design and maintain a large system procedurally, yous crazy). And despite my username, money has NOT been a big motivator. I've gone from job to job, I can usually get the work done perfect very quickly, any delays on my part are understandable (well about as understandable as it gets in the industry). But I ain't gonna work for peanuts because I got mouths to feed. Why do you program? Why do you do what you do?

    Read the article

  • OS-independent Inter-program communication between Python and C

    - by Gyppo
    I have very little idea what I'm doing here, I've never done anything like this before, but a friend and I are writing competing chess programs and they need to be able to communicate to each other. He'll be writing mainly in C, the bulk of mine will be in Python, and I can see a few options: Alternately write to a temp file, or successive temp files. As the communication won't be in any way bulky this could work, but seems like an ugly work-around to me, the programs will have to keep checking for change/new files, it just seems ugly. Find some way of manipulating pipes i.e. mine.py| ./his . This seems like a bit of a dead end. Use sockets. But I don't know what I'd be doing, so could someone give me a pointer to some reading material? I'm not sure if there are OS-independent, language independent methods. Would there have to be some kind of supervisor server program to administrate? Use some kind of HTML protocol, which seems like overkill. I don't mind the programs having to run on the same machine. What do people recommend, and where can I start reading?

    Read the article

  • Parse particular text from an XML string

    - by Dan Sewell
    Hi all, Im writing an app which reads an RSS feed and places items on a map. I need to read the lat and long numbers only from this string: http://www.xxxxxxxxxxxxxx.co.uk/map.aspx?isTrafficAlert=true&lat=53.647351&lon=-1.933506 .This is contained in link tags Im a bit of a programming noob but im writing this in C#/Silverlight using Linq to XML. Shold this text be extrated when parsing or after parsing and sent to a class to do this? Many thanks for your assistance. EDIT. Im going to try and do a regex on this this is where I need to integrate the regex somewhere in this code. I need to take the lat and long from the Link element and seperate it into two variables I can use (the results are part of a foreach loop that creates a list.) var events = from ev in document.Descendants("item") select new { Title = (ev.Element("title").Value), Description = (ev.Element("description").Value), Link = (ev.Element("link").Value), }; Question is im not quite ure where to put the regex (once I work out how to use the regex properly! :-) )

    Read the article

  • Moving x,y position of all array objects every frame in actionscript 3?

    - by Dylan Gallardo
    I have my code setup so that I have an movieclip in my library a class called "block" being duplicated multiple times and added into an array like this: function makeblock(e:Event){ newblock=new block; newblock.x=10; newblock.y=10; addChild(newblock); myarray[counter] = newblock; //adds a newblock object into array counter += 1; } Then I have a loop with a currently primitive way of handling my problem: stage.addEventListener(Event.ENTER_FRAME, gameloop); function gameloop(evt:Event):void { if (moveright==true){ myarray[0].x += 5; myarray[1].x += 5; myarray[2].x += 5 -(and so on)- My question is how can I change x,y values every frame for new objects duplicated into the array, along with the previous ones that were added. Of course with a more elegant way than writing it out myself... array[0].x += 5, array[1], array[2], array[3] etc. Ideally I would like this to go up to 500 or more array objects for one array so obviously I don't want to be writing it out individually haha, I also need it to be consistent with performance so using a for loop or something to loop through the whole array and move each x += 5 wouldn't work would it? Anyway, if anyone has any ideas that'd be great!

    Read the article

  • What is a good RPC model for building a AJAX web app using PHP & JS?

    - by user366152
    I'm new to writing AJAX applications. I plan on using jQuery on the client side while PHP on the server side. I want to use something like XML-RPC to simplify my effort in calling server-side code. Ideally, I wouldn't care whether the transport layer uses XML or JSON or a format more optimized for the wire. If I was writing a console app I'd use some tool to generate function stubs which I would then implement on the RPC server while the client would natively call into those stubs. This provides a clean separation. Is there something similar available in the AJAX world? While on this topic, how would I proceed with session management? I would want it to be as transparent as possible. For example, if I try to hit an RPC end-point which needs a valid session, it should reject the request if the client doesn't pass a valid session cookie. This would really ease my application development. I'd then have to simply handle the frontend using native JS functions. While on the backend, I can simply implement the RPC functions. BTW I dont wish to use Google Web Toolkit. My app wont be extremely heavy on AJAX.

    Read the article

  • Looking for a book which teaches how to write applications (as opposed to writng code)

    - by rumtscho
    I am not a developer. I have coded for fun and for university projects in several languages, and during an internship, I have written code which is still in use by a department of Fortune Global 500 company. I also have extensive theoretical knowledge of software engineering - process models, architecture, project management, UI construction using Lauesen's virtual windows... you get the picture. But I am not involved with software development in my job. I recently decided to start coding for fun again, and now I have some free days to do it. But this time, I want to do it right. I want to write a real, useful application, install it on my devices and use it myself. Also I want to publish it for others to use, should they want to do so. I am vaguely aware that there is more to writing an application than to writing code. There is stuff like version control software, decision for the right IDE, having a suite of unit tests, producing an installation package - and probably lots of other things I never thought of but which must be taken care of in a proper application, as opposed to a bunch of classes I am running from my IDE. All this is stuff I should know before I start, but I have not learned it. Coding books touch on some of the subjects like IDE choice, but don't go into detail, and are not exhaustive. Theoretical software engineering textbooks are even less helpful. So is there a book which teaches exactly that? I know that I can find information on each of these topics on the Internet, but I'd rather have a systematic book exhaustively listing all the things I should take care of if I want to create a good application, and offering the currently accepted solutions for them. In the best case, it will be language- and platform independent, but if you know of a good book focusing on a specific platform, I would like to know about it too. I know I want a lot, but given how important such knowledge is and how many people need it, surely somebody must have written such a book?

    Read the article

  • Setting pixel values in Nvidia NPP ImageCPU objects?

    - by solvingPuzzles
    In the Nvidia Performance Primitives (NPP) image processing examples in the CUDA SDK distribution, images are typically stored on the CPU as ImageCPU objects, and images are stored on the GPU as ImageNPP objects. boxFilterNPP.cpp is an example from the CUDA SDK that uses these ImageCPU and ImageNPP objects. When using a filter (convolution) function like nppiFilter, it makes sense to define a filter as an ImageCPU object. However, I see no clear way setting the values of an ImageCPU object. npp::ImageCPU_32f_C1 hostKernel(3,3); //allocate space for 3x3 convolution kernel //want to set hostKernel to [-1 0 1; -1 0 1; -1 0 1] hostKernel[0][0] = -1; //this doesn't compile hostKernel(0,0) = -1; //this doesn't compile hostKernel.at(0,0) = -1; //this doesn't compile How can I manually put values into an ImageCPU object? Notes: I didn't actually use nppiFilter in the code snippet; I'm just mentioning nppiFilter as a motivating example for writing values into an ImageCPU object. The boxFilterNPP.cpp example doesn't involve writing directly to an ImageCPU object, because nppiFilterBox is a special case of nppiFilter that uses a built-in gaussian smoothing filter (probably something like [1 1 1; 1 1 1; 1 1 1]).

    Read the article

  • [ask][php] find dynamic filename exist

    - by r4ccoon
    hi. i am writing a cache module in php. it tries to write a cache with a $string+timestamp as a filename. i dont have problem with writing the cache. the problem is i do a foreach loop to get the cache that i want. this is the logic that i use for getting the cache foreach ($filenames as $filename){ if(strstr($filename,$cachename)){//if found if(check_timestamp($filename,time())) display_cace($filename); break; } } but when it tries to get and read the cache, it slows the server down. imagine that i have 10000 cache file in a folder, and i need to check for every file in that cache folder. so how do you think the best way of doing this. here i explain again, because even me still dont understand my written question.. :D i write cache file with this format filename_timestamp.. e.g cache_function_random_news_191982899010 in a folder ./cache/ when i want to get the cache, i only pass "cache_function_random_news_" and check recursively on that folder. if i find something with that needle on a file name, display it, and break. but checking recursively on a 10000 files in a folder is not a good thing yeah? please give me your opinion ok, that would clarify more. thanks.

    Read the article

  • Comparing lists of field-hashes with equivalent AR-objects.

    - by Tim Snowhite
    I have a list of hashes, as such: incoming_links = [ {:title => 'blah1', :url => "http://blah.com/post/1"}, {:title => 'blah2', :url => "http://blah.com/post/2"}, {:title => 'blah3', :url => "http://blah.com/post/3"}] And an ActiveRecord model which has fields in the database with some matching rows, say: Link.all => [<Link#2 @title='blah2' @url='...post/2'>, <Link#3 @title='blah3' @url='...post/3'>, <Link#4 @title='blah4' @url='...post/4'>] I'd like to do set operations on Link.all with incoming_links so that I can figure out that <Link#4 ...> is not in the set of incoming_links, and {:title => 'blah1', :url =>'http://blah.com/post/1'} is not in the Link.all set, like so: #pseudocode #incoming_links = as above links = Link.all expired_links = links - incoming_links missing_links = incoming_links - links expired_links.destroy missing_links.each{|link| Link.create(link)} One route I've tried: I'd rather not rewrite Array#- and such, and I'm okay with converting incoming_links to a set of unsaved Link objects; so I've tried overwriting hash eql? and so on in Link so that it ignored the id equality that AR::Base provides by default. But this is the only place this sort of equality should be considered in the application - in other places the Link#id default identity is required. Is there some way I could subclass Link and apply the hash, eql?, etc overwriting there? The other route I've tried is to pull out the attributes hash for each Link and doing a .slice('id',...etc) to prune the hashes down. But this requires writing seperate methods for keeping track of the Link objects while doing set operations on the hashes, or writing seperate Collection classes to wrap the incoming_links hash-list and Link-list which seems a bit overkill. What is the best way to design this interaction? Extra credit for cleanliness.

    Read the article

  • Does BeginReceive() get everything sent by BeginSend()?

    - by IVlad
    I'm writing a program that will have both a server side and a client side, and the client side will connect to a server hosted by the same program (but by another instance of it, and usually on another machine). So basically, I have control over both aspects of the protocol. I am using BeginReceive() and BeginSend() on both sides to send and receive data. My question is if these two statements are true: Using a call to BeginReceive() will give me the entire data that was sent by a single call to BeginSend() on the other end when the callback function is called. Using a call to BeginSend() will send the entire data I pass it to the other end, and it will all be received by a single call to BeginReceive() on the other end. The two are basically the same in fact. If the answer is no, which I'm guessing is the case based on what I've read about sockets, what is the best way to handle commands? I'm writing a game that will have commands such as PUT X Y. I was thinking of appending a special character (# for example) to the end of each command, and each time I receive data, I append it to a buffer, then parse it only after I encounter a #.

    Read the article

  • Implementing comparision operators via 'tuple' and 'tie', a good idea?

    - by Xeo
    (Note: tuple and tie can be taken from Boost or C++11.) When writing small structs with only two elements, I sometimes tend to choose a std::pair, as all important stuff is already done for that datatype, like operator< for strict-weak-ordering. The downsides though are the pretty much useless variable names. Even if I myself created that typedef, I won't remember 2 days later what first and what second exactly was, especially if they are both of the same type. This gets even worse for more than two members, as nesting pairs pretty much sucks. The other option for that is a tuple, either from Boost or C++11, but that doesn't really look any nicer and clearer. So I go back to writing the structs myself, including any needed comparision operators. Since especially the operator< can be quite cumbersome, I thought of circumventing this whole mess by just relying on the operations defined for tuple: Example of operator<, e.g. for strict-weak-ordering: bool operator<(MyStruct const& lhs, MyStruct const& rhs){ return std::tie(lhs.one_member, lhs.another, lhs.yet_more) < std::tie(rhs.one_member, rhs.another, rhs.yet_more); } (tie makes a tuple of T& references from the passed arguments.) Edit: The suggestion from @DeadMG to privately inherit from tuple isn't a bad one, but it got quite some drawbacks: If the operators are free-standing (possibly friends), I need to inherit publicly With casting, my functions / operators (operator= specifically) can be easily bypassed With the tie solution, I can leave out certain members if they don't matter for the ordering Are there any drawbacks in this implementation that I need to consider?

    Read the article

  • Guidelines for creating a programming-language enjoyable to write programs in?

    - by sub
    I'm currently working on the topic of programming-languages and interpreter-design. I have already created several programming languages but couldn't reach my goal so far: Create a programming-language which focuses on giving the programmer a good feeling when writing code in it. It should just be fun and/or interesting and in no case annoying to write something in it. I get this feeling when writing code in Python. I sometimes get the opposite with PHP and in rare cases when having to reinvent some wheel in C++. So I've tried to figure out some syntactical features to make programming in my new language fun, but I just can't find any. Which concrete features, maybe mainly in terms of syntax, do/could make programming in a language fun? Examples: I find it enjoyable to program in Ruby because of it's use of code blocks. It would be nice if you could include exactly one example in your answer Those features do not have to already exist in any language! I'm doing this because I have experienced extreme rises in (my own) productivity when programming in languages I love (because of particular features).

    Read the article

  • Hibernate Performance Best Practice?

    - by user829237
    Im writing a Web application using Hibernate 3. So, after a while i noticed that something was slow. So i tested hibernate profiler and found that hibernate will make unreasonably many db-calls for simple operation. The reason is ofcourse that i load an Object (this object has several "parents") and these "parents" have other "parents". So basicly hibernate loads them all, even though i just need the basic object. Ok, so i looked into lazy-loading. Which lead me into the Lazyloading-exception, because i have a MVC webapp. So now i'm a bit confused as to what is my best approach to this. Basicly all I need is to update a single field on an object. I already have the object-key. Should I: 1. Dig into Lazy-loading. And then rewrite my app for a open-session-view? 2. Dig into lazy-loading. And then rewrite my dao's to be more specific. E.g. writing DAO-methods that will return objects instanciated with only whats necessary for each use-case? Could be a lot of extra methods... 3. Scratch hibernate and do it myself? 4. Cant really think of other solutions right now. Any suggestions? What is the best practice?

    Read the article

  • PHP form validation function

    - by Barbs
    I am currently writing some PHP form validation (I have already validated clientside) and have some repetitive code that I think would work well in a nice little PHP function. However I have having trouble getting it to work. I'm sure it's just a matter of syntax but I just can't nail it down. Any help appreciated. //Validate phone number field to ensure 8 digits, no spaces. if(0 === preg_match("/^[0-9]{8}$/",$_POST['Phone']) { $errors['Phone'] = "Incorrect format for 'Phone'"; } if(!$errors) { //Do some stuff here.... } I found that I was writing the validation code a lot and I could save some time and some lines of code by creating a function. //Validate Function function validate($regex,$index,$message) { if(0 === preg_match($regex,$_POST[$index],$message) { $errors[$index] = $message; } And call it like so.... validate("/^[0-9]{8}$/","Phone","Incorrect format for Phone"); Can anyone see why this wouldn't work? Note I have disabled the client side validation while I work on this to try to trigger the error, so the value I am sending for 'Phone' is invalid.

    Read the article

  • Is it best to make fewer calls to the database and output the results in an array?

    - by Jonathan
    I'm trying to create a more succinct way to make hundreds of db calls. Instead of writing the whole query out every time I wanted to output a single field, I tried to port the code into a class that did all the query work. This is the class I have so far: class Listing { /* Connect to the database */ private $mysql; function __construct() { $this->mysql = new mysqli(DB_LOC, DB_USER, DB_PASS, DB) or die('Could not connect'); } function getListingInfo($l_id = "", $category = "", $subcategory = "", $username = "", $status = "active") { $condition = "`status` = '$status'"; if (!empty($l_id)) $condition .= "AND `L_ID` = '$l_id'"; if (!empty($category)) $condition .= "AND `category` = '$category'"; if (!empty($subcategory)) $condition .= "AND `subcategory` = '$subcategory'"; if (!empty($username)) $condition .= "AND `username` = '$username'"; $result = $this->mysql->query("SELECT * FROM listing WHERE $condition") or die('Error fetching values'); $info = $result->fetch_object() or die('Could not create object'); return $info; } } This makes it easy to access any info I want from a single row. $listing = new Listing; echo $listing->getListingInfo('','Books')->title; This outputs the title of the first listing in the category "Books". But if I want to output the price of that listing, I have to make another call to getListingInfo(). This makes another query on the db and again returns only the first row. This is much more succinct than writing the entire query each time, but I feel like I may be calling the db too often. Is there a better way to output the data from my class and still be succinct in accessing it (maybe outputting all the rows to an array and returning the array)? If yes, How?

    Read the article

  • How to write a cgi script in perl that accepts output (an image file) from a urlconnection in a Java applet and writes it to the server?

    - by Brad Rock
    I created a Java applet for my web page that creates an image file. I want users to be able to run the applet and create unique images, click a button, and have the image they created be saved to the web server. I think I have the code down for writing the image to a URLconnection in the Java applet itself after having successfully written a file while running the applet on my system rather than the web page and saving a file to the local disk, and then altering a few things to write to a URLConnection instead of to the local disk (although we shall see how that works too). I am now trying to write a cgi script in perl that takes the image output from the URLConnection and writes the image to a file on my web server (note: I am a newbie to perl). I have found many examples of how to do something similar with simple text coming from an applet and then writing it to a text file, but I want to know how to apply the same concept to an image. Particularly, how do I read in the image? I've seen text input get read by using read(STDIN, $some_variable)--does the same thing work with an image? Likewise, how do I write the image file? What function do I use? Thanks for your help. I know that I am rather naive about all of this.

    Read the article

< Previous Page | 145 146 147 148 149 150 151 152 153 154 155 156  | Next Page >