Friday, February 11, 2011

What's the single most important piece of documentation?

You are joining a project to maintain an existing system. There is no written documentation at all, but the previous team offers to write one piece of documentation. And they are going to let you decide what it should cover: What is the single most important piece of documentation?

This is a poll: give only one document type per answer and let other readers vote.

  • Full system test specification for the whole system.

    jop : +1. I'll ask my friends to vote for this too. :)
    Greg Dean : It appears that you have 7 friends. Stop using SO
    From David
  • If I can only get one part of the documentation, I want to know the overall design and how things are supposed to fit together and work with each other. The hardest part of any new system is figuring out the landscape. The rest is just work.

  • A high level roadmap. Where do I find the major functional areas, and how do they tie together?

    From Andrew
  • Doxygen (or doxygen-like) documentation for the source code. Completed, please, no forgetting to write the tags for half the classes.

    From Throctukes
  • Crazy question - "one piece"? What is the "piece" of documentation?

    My request would be to create a "complete documentation, at least 500 pages of written text". Is that one piece? :)

    1800 INFORMATION : You mean "8 meters of written documentation", right? http://thedailywtf.com/Articles/Very,_Very_Well_Documented.aspx
    From Suma
  • How to set up the development environment: A step-by-step instruction which gives you a complete environment in which to check-in/check-out code, build, debug, deploy, test, run and perform all your daily tasks.

  • Contact details for the original development team.

    Failing that, I would definatly say a software build document describing how to manage, modify and build the codebase. Alongside a list of known 'gotchas'.

    brian d foy : Along with that, what sort of beer they like to drink so you know how to bribe them :)
    From TK
  • A Good (TM) description of the problem domain and what the application is supposed to do.

    6eorge Jetson : Agreed! When the problem domain is well understood, the typical slew of use cases can be refactored/reduced to an underlying core set. Programming against this core set should position the app to be within small solution domain tweaks to address the "edge case/last mile" requirements
    Andrew : The business should be able to supply that. It shouldn't need to come from the previous team.
  • Detailed requirements of what the application is supposed to do. Good luck though, I have never managed to get this. Even from an army of documenters, willing to write billions of documents.

    From Greg Dean
  • obviously there's no real answer to this situation. whatever technical documentation you choose, you're going to have to dig into the system and figure it out. IMHO, and I'm not trying to be a smart ass here, the most important piece of documentation in this case is "how things got to be the way they are"- an organization politics/resources review of the conditions that led to the "no documentation and project is being transferred to another team" situation.

    Arne Evertsson : Interesting answer! I didn't think of the political aspect.
    From Amir Arad
  • Not documentation in the traditonal sense, but a virtual machine or ghosted image of the working build/test machine would be very useful.

    How to set up the development environment would be most useful though.

    From Ash
  • For existing projects, assuming that the testing is end to end, the test scripts act as an accurate source of status-quo. Most often documents don't get uplifted to represent the updates, but test cases are. However, the test cases are seriously limited in that they fail to provide the rational behind why the system is designed so/exists so. An architecture diagram is needed complement this.

    From questzen
  • Step-by-Step disaster recovery procedure.

  • What the business rules & reasons for each decision are.

    Everything else can be done by any good developer - but without knowing the business reasons for functionality, you're doomed.

  • For databases ERD. All else, unit tests.

  • Project log - we're great believers that when key decisions are made you should be recording why you chose to go down a particular route and more importantly why you chose not go down an alternative route.

    Having this in place helps to stop future developers from making the same mistakes again and wasting a lot of time.

    From Carl
  • I want the docs for all of the data structures. When and how they are used, what each of their members are, and what they store. I especially want to know how the data structures map to the problem being solved. If I understand the data structures, then I can often skip most of the code, because I can guess what it does. If I don't understand the data structures, then I need to read a bunch of code to figure out when and how they are changed and what they're supposed to hold and why.

    From Glomek
  • this is a pretty good question, not that you would ever get a situation like this (you will generally get zero documentation).

    my choice is a toss-up between two things: a system test plan as others have said, so no surprise there. reason being is that test-cases teach you how the software works. at least the style of test plan i use does (i did a blog article on this, shameless plug -> http://pm4web.blogspot.com/2008/07/writing-system-test-plan.html).

    the other one i would go with, and this may seem a little strange, so bare with me - is a project schedule. i dont know how relevant this would be for an already established system, but i have had it a few times now where ive arrived at a new company and been greeted with a disaster zone (i.e. projects running behind schedule, clients laying siege to our office, etc). the single biggest help would of been if i stopped and created a project schedule, outlining all the tasks needed to achieve the business objectives. you cant create a decent schedule without understanding the system along the way.

    • LM
    From louism
  • A list of administrator logins.

    From elmnoise

Automatic Update and checkin of AssemblyInfo.cs files occasionally causes partial fail

We have TFS 2008 our build set up to checkout all AssemblyInfo.cs files in the project, update them with AssemblyInfoTask, and then either undo the checkout or checkin depending on whether the build passed or not. Unfortunately, when two builds are queued close together this results in a Partially completed build as the AssemblyInfo.cs files seem to be checked out at an earlier version to the previous checkin.

In order to get around this I thought that I could use the "Get" task to force the AssemblyInfo.cs files to the latest version before updating them, but this appears to have no effect. Any ideas?

<Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true'">
<Message Text="SolutionRoot = $(SolutionRoot)" />
<Message Text="OutDir = $(OutDir)" />
<!-- Set the AssemblyInfoFiles items dynamically -->
<CreateItem Include="$(SolutionRoot)\Main\Source\InputApplicationSln\**\$(AssemblyInfoSpec)">
  <Output ItemName="AssemblyInfoFiles" TaskParameter="Include" />
</CreateItem>

<Message Text="$(AssemblyInfoFiles)" />

<!-- When builds are queued up successively, it is possible for the next build to be set up before the AssemblyInfoSpec is checked in so we need to force 
    the latest these versions of these files to be got before a checkout -->
<Get Condition=" '$(SkipGet)'!='true' " TeamFoundationServerUrl="$(TeamFoundationServerUrl)" Workspace="$(WorkspaceName)" Filespec="$(AssemblyInfoSpec)"  Recursive="$(RecursiveGet)" Force="$(ForceGet)" />

<Exec WorkingDirectory="$(SolutionRoot)\Main\Source\InputApplicationSln"
    Command="$(TF) checkout /recursive $(AssemblyInfoSpec)"/>

  • Does your build re-write the AssemblyInfo files and then check them back in? Or do you just modify the AssemblyInfo files locally. Personally I prefer the latter approach - as documented over at the TFSBuild recipies site:

    http://tfsbuild.com/AssemblyVersioning%20.ashx

    I've never actually sat down and checked but I was wondering if you checked in the AssemblyInfo files then could the following be happening which might be causing your problems...

    1. Request a build, current changeset = 42
    2. Build 1 for changeset 42 starts running
    3. Request a build, current changeset = 42 (still)
    4. Build 2 for changeset 42 queued
    5. Build 1 checks in new assemblyinfo files, current changeset = 43
    6. Build 1 completes
    7. Build 2 for changeset 42 starts, dows a get of changeset 42 meaning AssemblyInfo files are the fold ones.

    As I say, not exactly sure when the changeset number is determined for the build - at the time of queuing or at the time of running. It would make more sense for it to be at the time of queueing though.

    Damien Ryan : You're right, we check out, modify and then, once the build has succeeded, check in again. This is to make sure that the modified AssemblyInfo.cs matches our modified build number and to help if we need to rebuild a previous version. I'm assuming the second get command isn't the way to go?
  • Changing:

    <Get Condition=" '$(SkipGet)'!='true' " TeamFoundationServerUrl="$(TeamFoundationServerUrl)" Workspace="$(WorkspaceName)" Filespec="$(AssemblyInfoSpec)"  Recursive="$(RecursiveGet)" Force="$(ForceGet)" />
    

    To:

    <Get Condition=" '$(SkipGet)'!='true' " TeamFoundationServerUrl="$(TeamFoundationServerUrl)" Workspace="$(WorkspaceName)" Filespec="$(AssemblyInfoSpec)"  Recursive="True" Force="True" />
    

    Has forced the AssemblyInfo.cs files to be overwritten with top of tree. It's been working so far, but is more of a hack than something elegant.

wxPython: displaying multiple widgets in same frame

I would like to be able to display Notebook and a TxtCtrl wx widgets in a single frame. Below is an example adapted from the wxpython wiki; is it possible to change their layout (maybe with something like wx.SplitterWindow) to display the text box below the Notebook in the same frame?

import wx
import wx.lib.sheet as sheet

class MySheet(sheet.CSheet):
    def __init__(self, parent):
        sheet.CSheet.__init__(self, parent)

        self.SetLabelBackgroundColour('#CCFF66')
        self.SetNumberRows(50)
        self.SetNumberCols(50)


class Notebook(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(600, 600))
        menubar = wx.MenuBar()
        file = wx.Menu()
        file.Append(101, 'Quit', '' )
        menubar.Append(file, "&File")
        self.SetMenuBar(menubar)
        wx.EVT_MENU(self, 101, self.OnQuit)
        nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM)
        self.sheet1 = MySheet(nb)
        self.sheet2 = MySheet(nb)
        self.sheet3 = MySheet(nb)
        nb.AddPage(self.sheet1, "Sheet1")
        nb.AddPage(self.sheet2, "Sheet2")
        nb.AddPage(self.sheet3, "Sheet3")
        self.sheet1.SetFocus()
        self.StatusBar()

    def StatusBar(self):
        self.statusbar = self.CreateStatusBar()

    def OnQuit(self, event):
        self.Close()


class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(450, 400))
        self.text = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE)
        self.Center()

class MyApp(wx.App):
    def OnInit(self):
        frame = Notebook(None, -1, 'notebook.py')
        frame.Show(True)
        frame.Center()
        frame2 = MyFrame(None, -1, '')
        frame2.Show(True)
        self.SetTopWindow(frame2)
        return True


app = MyApp(0)
app.MainLoop()
  • You can use a splitter, yes.

    Also, it makes sense to create a Panel, place your widgets in it (with sizers), and add this panel to the Frame.

    bvmou : Could you add a few tips on how I might do that, with reference to the above classes?
  • Making two widgets appear on the same frame is easy, actually. You should use sizers to accomplish this.

    In your example, you can change your Notebook class implementation to something like this:

    class Notebook(wx.Frame):
        def __init__(self, parent, id, title):
            wx.Frame.__init__(self, parent, id, title, size=(600, 600))
            menubar = wx.MenuBar()
            file = wx.Menu()
            file.Append(101, 'Quit', '' )
            menubar.Append(file, "&File")
            self.SetMenuBar(menubar)
            wx.EVT_MENU(self, 101, self.OnQuit)
            nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM)
            self.sheet1 = MySheet(nb)
            self.sheet2 = MySheet(nb)
            self.sheet3 = MySheet(nb)
            nb.AddPage(self.sheet1, "Sheet1")
            nb.AddPage(self.sheet2, "Sheet2")
            nb.AddPage(self.sheet3, "Sheet3")
            self.sheet1.SetFocus()
            self.StatusBar()
            # new code begins here:
            # add your text ctrl:
            self.text = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE)
            # create a new sizer for both controls:
            sizer = wx.BoxSizer(wx.VERTICAL)
            # add notebook first, with size factor 2:
            sizer.Add(nb, 2)
            # then text, size factor 1, maximized
            sizer.Add(self.text, 1, wx.EXPAND)
            # assign the sizer to Frame:
            self.SetSizerAndFit(sizer)
    

    Only the __init__ method is changed. Note that you can manipulate the proportions between the notebook and text control by changing the second argument of the Add method.

    You can learn more about sizers from the official Sizer overview article.

    bvmou : This is extremely helpful, thank you DzinX
    From DzinX

Disable the error message box while loading an external movie with actionscript 3

I have a compiled swf file and a I can't edit it, but the movie is working fine (but gives an error message with a message box).

I am using it from an other movie (load with as3 code). When the loader movie loads it the error message box appears.

I wonder is it possible to disable the errors while loading a movie with as3.


Here is the error in the message box:

"TypeError: Error #1009: Cannot access a property or method of a null object reference.
at motionsound11_fla::_all_29/motionsound11_fla::frame249()"
  • Can you elaborate on what the error is? This might help figure out if there's a workaround for that specific error, or maybe that its not possible to supress (for example, the box warning of a blocked local or network access attempt).

    If you google for 'swf decompiler' you'll find a myriad of options for generating some actionscript for your SWF, which might allow you to fix the problem directly, or at least diagnose it further.

    From Paul Dixon
  • Yes. Here is the error message (editted my first post):

    "TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at motionsound11_fla::_all_29/motionsound11_fla::frame249()"
    

    And I don't want to decompile my movie. It becomes more complex when decompiled. Yes, for understanding the problem I did. But my first problem is disable the error message box.

    Thanks so much.

  • I might be wrong here, but I'm not sure the release version of Flash player plugin would produce an error like that - are you running this in the debug plugin? What you could do is test on a box you know has never been used for development - it's possible the error simply won't appear when you deploy your application.

    That said, any Flash developers who use your app might still see it!

    Hasan Tayyar BEŞİK : The loader wont be on a web page. It will be used as .swf file or executable file
    Hasan Tayyar BEŞİK : Now i decide to publish as web page. This way, the project will be more secure and dynamic. Thanks
    From Paul Dixon
  • Yes, You are right. There is no error in a browser (with flash player plugin). My project wont be in a browser. It will be an executable file (.exe) or .swf . So people who have "Adobe Flash CS3" on their computers will see the error in swf format file.

    (i will add this information to my question : " The loader wont be on a web page. It will be used as .swf file or executable file" )

    And your answer is acceptable. I will publish as html page not .exe or .swf. This will be more secure,dynamic and has no platform dependence.

    Thanks.

What happens when I edit web.config?

I need to edit the web.config file on a live Sharepoint environment, but I'm unsure what will happen if I do (I want to output custom errors).

Will this cause the IIS6 worker process to recycle?

Will active users lose their session state because of this?

Or can I safely edit the file?

  • I believe this resets the application and user's will lose session state.

    From RyanFetz
  • It will make the application restart.

    From Kristian
  • The app pool recycles and as such session state is lost.

    From SteveCl
  • Yes, the AppPool will recycle and session state will be lost.

    From JacquesB
  • The application pool will restart and session state will be lost. Imagine each ASP.NET application (as defined in IIS) is a program on the desktop. Saving web.config will do something similar to closing the program and reopening it.

    1. Yes. It will be recycled.
    2. Yes. They will lose their session.
    3. Yes. You can safely edit the file. I suggest you to read this MSDN article : Working with web.config Files in Windows SharePoint Services
    willem : A very useful MSDN article. Thank you!
  • If you have any thoughts of editing the web config, please look into the SPWebConfigModification class.

  • As already mentioned by some people: the application pool of the site in IIS will restart (this typically takes a couple of seconds). As a result the next page request(s) will be slower (since nothing will be cached anymore). Also the session state of the users will be lost; BUT in WSS session state is not used by default, in MOSS it is used by InfoPath Form Services. So it could be that you don't have big issues related to losing session state.

    On the other side; to overcome those issues: what is typically done is to create a SharePoint Solution (WSP) that deploys and starts a Timer Job to make the changes to the web.config from code (using the SPWebConfigModification class of the Object Model). The nice thing is that you can schedule the execution of the change, so your users won't notice it.

  • Also if Session state is configured as out-of-process (database or service) then recycling the app pool won't lose any session state. This is as true for Sharepoint as it is for vanilla ASP.Net.

    From piers7
  • Concur with all of the above, I'd also like to point out that a backup (just a quick file copy even) of any manually edited web.config file is handy in case you screw up a quotation mark somewhere and break your website :-)

    From tekiegreg

What kind of programming environment do you use to write your Windows-based Games?

I've used XNA and Visual Studio 2005 integrated with Flash. I'm curious to see what environments other people use and prefer.

  • Same. XNA 2.0 in VS2005 or XNA 3.0 in VS2008.

    I've also dabbled in darkGDK when I feel like some C++.

    Joe Morgan : I'll have to check into darkGDK - I've not done C++ in 3 or 4 years, but it's where I got my start. Thanks for the suggestion.
    From JTA
  • Although not Windows-specific, I have used pygame, which can use DirectX as a backend.

  • I use Dev-C++ and SDL

    From jwarzech
  • I developed some cross-platform 2D games (Windows as well) and used C++ with Geany and SDL.

    I find SDL to be a great library to make casual games. Of course, if cross-platform means Windows and XBOX for you, then there are other libraries that might be a better choice.

  • At Flying Lab for Pirates of the Burning Sea we used Visual Studio 2005. At Divide by Zero for we use Visual Studio 2008.

    From Joe Ludwig
  • Visual Studio 2008 with XNA 3.0 CTP is what I'm using at the moment. A lot of game development shops are still using VS05, however.

    From TraumaPony

Properly file Designer Files in ASP.NET Web Sites

I need to get existing web pages into an existing ASP.NET web site in Visual Studio 2008. I simply tried to drag and drop the whole file folder content into the Visual Studio Solution Explorer or even to copy them into the web site folder.

Both ways, Visual Studio seems unable to map the .designer.cs files to the corresponding .aspx (or .master) file, even after restarting the whole IDE. The Solution Explorer entry looks in a way like this:

- Main.aspx
    Main.aspx.cs
  Main.aspx.designer.cs

Can I make Visual Studio file the designer-file below the aspx-file in any way? Building the website becomes a problem too that way, but that's the next problem I'm going to work on. :-)

I strongly hope there is a simpler way than manualle creating each file and copying and pasting the contents into each file by hand.

Thank you for any idea!

Cheers Matthias

  • try copying the files through the filesystem and then right clicking on the project and selecting to add an existing item at which point you can choose all at once and this usually puts them in the proper places.

    From YonahW
  • Kind of partially self-answering my question:

    In a web project - in contrast to a web site - it works perfectly through drag and drop onto the solution explorer, as I did for the web site before. To make the decision which type of "web site unit" to use there is another thread here on stackoverflow: ASP.NET Web Site or Web Project.

    In a web site I can't even use YonahW's solution, because I can't just put files into the proper web site directory without causing them to be added to the web site automatically. Thanks to you anyway, YonahW. :-)

    From Mudu
  • It sounds like you are trying to bring web application files into a web site. IIf that is the case, The designer files are not even needed. Just dont include them. They are generated and compiled in at runtime when the website runs.

    Mudu : Thank you! Sometimes solutions are that simple and comprehensible, but you just need to know...
    From mattlant

Good Examples of .NET Desktop Applications

I would like to evaluate .NET as a development platform for a desktop application. I am looking for good examples of .NET desktop applications used in the mainstream. The only ones I know of are:

  1. Visual Studio (The copy website form is one example.)
  2. Team Explorer UI
  3. Paint.NET
  4. Reflector
  5. Gnome Do (An app launcher for Gnome; runs on Mono)

I am looking for more examples; open source, freeware or a demo version in that order.

Suggestions?

  • I have this Game Neverwinter Nights 2, quite a big thing, and it has some SharpZipLib and QWhale DLLs included. Should be dotNet

    From Midhat
  • There are lots of desktop apps done in .NET, only most of them are internal/enterprise apps in companies, not mass-market products.

    The only downside I see to doing a mass-market desktop app in .NET is the need to distribute the .NET Framework with it. Of course with the advent of Windows Vista, .NET already comes preinstalled.

    Max Schmeling : .Net comes preinstalled on XP too.
    Michael Damatov : In fact, you will want to use .NET 3.5 so some sort of distribution is still needed, even on Vista.
    From cruizer
  • Windows Media Center has a managed API I believe. I'm not sure how much .Net stuff is in WMC, but you can check it out.

  • I found this from the related questions list.

    Most notable are Gnome applications running on Mono/Linux. Tomboy, Beagle and F-Spot!

  • Check for WPF(.NET3.5) applications

    http://www.thirteen23.com/experiences/desktop/

    WPF app by Frog design

    From Jobi Joy
  • Windows Live Writer

    From Mark Heath
  • SharpDevelop is an open source Development IDE for .NET very much like VS.NET written in .NET (iirc it still has some pinvokes, but it is all managed code) and is quite large and feature complete.

    You can even get the source code for it to look at.

    Vulcan Eager : Awesome! How did I miss this?!
    From mattlant
  • Comicster! :)

  • slimKEYS is written in C# with some p/invokes.

  • From Mark Heath
  • Icarus (screenshots here), the GUI of Gallio/MbUnit OSS testing platform.

ASP.NET MVC "CRUD" Database Sample

I'm trying to get my head around ASP.NET MVC coming from a LAMP development environment. This isn't for anything production or mission-critical, just a guy trying to learn. I've looked at all I can on http://asp.net/mvc but a lot of those videos and tutorials seem to assume you know ASP.NET WebForms (which I don't) although I am quite handy with VB.NET.

My question boils down to, does anyone know of a small tutorial or even have one they made themselves whilst exploring ASP.NET MVC, that literally just shows you how to create, read, update and delete records in an MS SQL database?

  • This question is a little tricky.

    Most Microsoft data access tutorials you will see on the net involve controls that will require you to drag datasource objects into an ASP.NET page, and I'm not sure (actually I seriously doubt) that those things work on ASP.NET MVC.

    That being said, Rob Conery has a great tutorial series on setting up an ASP.NET MVC Storefront application, and this is a really great resource on putting up an ASP.NET MVC application, including but not limited to data access (he used LINQ to SQL).

    From Jon Limjap
  • IMHO getting started with asp.net mvc from LAMP background should not be so difficult, if you have some experience with java. if you need intro tutorials, beside scott hanselman's intro videos on www.asp.net/mvc, there are scott guthrie's introductory blog posts on weblogs.asp.net/scottgu, although they're bit outdated.

    you can create basic mvc web app and then see common ui patterns from that example. you don't need to use (almost) any of asp.net server controls, you can use html helpers that are part of asp.net mvc, Good examples of data retrieval with LINQ2SQL are outlined also on scottgu's blog.

  • I just created a scaffolder that will generate this code for you in a nice testable way - my stab at "how it should be done" in a CRUD fashion. Have a look:

    http://blog.wekeroad.com/blog/subsonic-mvc-scaffold-addin/

    From Rob Conery
  • How about you try to use a scaffold generator just like Rails? It is available at http://www.twinforms.com/aspmvc-home.htm

    then you can skip from step 1 to 3.

    Hope this helps

    From Jirapong
  • Did you look at Evolutility CRUD framework?

    http://www.evolutility.org

Add record to SqlDataReader

Is there any way I can push a new record to SqlDataReader after i pull a table down? I have this piece of trash code that I need to modify, and this seems like the easiest way to do what I need. I understand that this should not be done, and if you have to do it there is something seriously wrong with your logic, but is there a way?

  • SqlDataReaders are forward read only so I doubt you can add a record in (regardless of whether you have pulled the whole table down). In fact anything that inherits DbDataReader is forward read only.

    I'm guessing you need to do some manipulation with the records. Maybe what you can do instead is use the SqlDataReader to fill a DataTable and put a new record into the DataTable. But then you'd need to change your code to juggle a DataTable.

    From fung
  • Easiest way from that point is to just manually create a command with a command string of an insert(parametized if not sanitized/clean data, best to do that anyways, but could make code bulkier). Code for that should be quite small, considering you already have everything else setup.

    From mattlant
  • When you say "push a new record to"... do you mean you want to add a record to the results? Or do you mean you want to do an INSERT?

    The INSERT cannot be done with a reader; however, you can do things with readers. Of course, it would be simpler to update the original query so that you UNION the data.

    In particular: you can't create your own SqlDataReader, but you can create your own bespoke IDataReader implementation; this could wrap the SqlDataReader, simply proxying data from the inner SqlDataReader until the SqlDataReader.Read() method returns false - then you could swap to returning you own data, returning true until you have run out of data. Not trivial to implement (mainly because you need to implement a lot of methods to write your own IDataReader), but certainly not impossible.

  • You need to expand your question a bit,

    If, for example, you need to walk through a million records and update a field on the same table while walking through the data.

    You can create a second SqlConnection to your db and execute update statements on the table (prone to locking issues), or better still insert all your changes into a temp table and merge the changes back into the original table after you are done with the reader.

    There is little question I am tempted to ask, can this piece of logic be replaced with a single SQL UPDATE statement?

How do I use owfs to read an iButton temperature logger?

I've installed owfs and am trying to read the data off a iButton temperature logger.

owfs lets me mount the iButton as a fuse filesystem and I can see all the data. I'm having trouble figuring out what is the best way to access the data though. I can get individual readings by catting the files, e.g. cat onewire/{deviceid}/log/temperature.1, but the onewire/{deviceid}/log/temperature.ALL file is "broken" (possible too large, as histogram/temperature.ALL work fine).

A python script to read all files seems to work but takes a very long time. Is there a better way to do it? Does anyone have any examples?

I'm using Ubuntu 8.04 and couldn't get the java "one wire viewer" app to run.

Update: Using owpython (installed with owfs), I can get the current temperature but can't figure out how to get access to the recorded logs:

>>> import ow
>>> ow.init("u") # initialize USB
>>> ow.Sensor("/").sensorList()
[Sensor("/81.7FD921000000"), Sensor("/21.C4B912000000")]
>>> x = ow.Sensor("/21.C4B912000000")
>>> print x.type, x.temperature
DS1921           22

x.log gives an AttributeError.

  • I don't think there is a clever way. owpython doesn't support that telling from the API documentation. I guess /proc is your safest bet. Maybe have a look at the source of the owpython module and check if you can find out how it works.

    Tom : I wasn't able to find any documentation other than the docstrings. Is there anything else?
  • I've also had problems with owfs. I found it to be an overengineered solution to what is a simple problem. Now I'm using the DigiTemp code without a problem. I found it to be flexible and reliable. For instance, I store the room's temperature in a log file every minute by running

    /usr/local/bin/digitemp_DS9097U -c /usr/local/etc/digitemp.conf \
        -q -t0 -n0 -d60 -l/var/log/temperature
    

    To reach that point I downloaded the source file, untarred it and then did the following.

    # Compile the hardware-specific command
    make ds9097u
    # Initialize the configuration file
    ./digitemp_DS9097U -s/dev/ttyS0 -i
    # Run command to obtain temperature, and verify your setup
    ./digitemp_DS9097U -a 
    # Copy the configuration file to an accessible place
    cp .digitemprc /usr/local/etc/digitemp.conf
    

    I also hand-edited my configuration file to adjust it to my setup. This is how it ended-up.

    TTY /dev/ttyS0
    READ_TIME 1000
    LOG_TYPE 1
    LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
    CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
    HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
    SENSORS 1
    ROM 0 0x10 0xD3 0x5B 0x07 0x00 0x00 0x00 0x05
    

    In my case I also created a /etc/init.d/digitemp file and enabled it to run at startup.

    #! /bin/sh
    #
    # System startup script for the temperature monitoring daemon
    #
    ### BEGIN INIT INFO
    # Provides: digitemp
    # Required-Start:
    # Should-Start:
    # Required-Stop:
    # Should-Stop:
    # Default-Start:  2 3 5
    # Default-Stop:   0 1 6
    # Description:    Start the temperature monitoring daemon
    ### END INIT INFO
    
    DIGITEMP=/usr/local/bin/digitemp_DS9097U
    test -x $DIGITEMP || exit 5
    
    DIGITEMP_CONFIG=/root/digitemp.conf
    test -f $DIGITEMP_CONFIG || exit 6
    
    DIGITEMP_LOGFILE=/var/log/temperature
    
    # Source SuSE config
    . /etc/rc.status
    
    rc_reset
    case "$1" in
        start)
            echo -n "Starting temperature monitoring daemon"
            startproc $DIGITEMP -c $DIGITEMP_CONFIG  -q -t0 -n0 -d60 -l$DIGITEMP_LOGFILE
            rc_status -v
            ;;
        stop)
            echo -n "Shutting down temperature monitoring daemon"
            killproc -TERM $DIGITEMP
            rc_status -v
            ;;
        try-restart)
            $0 status >/dev/null && $0 restart
            rc_status
            ;;
        restart)
            $0 stop
            $0 start
            rc_status
            ;;
        force-reload)
            $0 try-restart
            rc_status
            ;;
        reload)
            $0 try-restart
            rc_status
            ;;
        status)
            echo -n "Checking for temperature monitoring service"
            checkproc $DIGITEMP
            rc_status -v
            ;;
        *)
            echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
            exit 1
            ;;
    esac
    rc_exit
    
    Tom : Thanks for the info, but I don't think that helps getting access to the log stored on the DS1922T. I can read the current temperature using owpython or owfs, it's just accessing the stored measurements that I'm struggling with.
  • This is crazy complicated. Has anybody figured out a SIMPLE way to do this? I used to be able to get the onewire viewer to work in Windows, but I can't get it to work in Ubuntu. The OWFS just plain confounds me, and digitemp is no better. All that configuration for such a simple little device? I can interface with my mobile phone with less config than that!

    Any smart solutions out there?

    From mlissner
  • Well I have just started to look at ibuttons and want to use python.

    This looks more promising:

    http://www.ohloh.net/p/pyonewire

    From Buteman

Quick and dirty way to compare SQL server performance

Further to my previous question about the Optimal RAID setup for SQL server, could anyone suggest a quick and dirty way of benchmarking the database performance on the new and old servers to compare them? Obviously, the proper way would be to monitor our actual usage and set up all sorts of performance counters and capture the queries, etc., but we are just not at that level of sophistication yet and this isn't something we'll be able to do in a hurry. So in the meanwhile, I'm after something that would be a bit less accurate, but quick to do and still better than nothing. Just as long as it's not misleading, which would be worse than nothing. It should be SQL Server specific, not just a "synthetic" benchmark. It would be even better if we could use our actual database for this.

  • you can always insert, read, and delete a couple of million rows - it's not a realistic mix of operations but it should strain the disks nicely...

  • Find at least a couple of the queries that are taking some time, or at least that you suspect are taking time, insert a lot of data if you don't have it already, and run the queries having set: SET STATISTICS IO ON SET STATISTICS TIME ON SET STATISTICS PROFILE ON Those should give you a rough idea of the resources being consumed.

    You can also run SQL Server Profiler to get a general idea of what queries are taking a long time and how long they are taking plus other statistics. It outputs a lot of data so try to filter it down a little bit, possibly by long duration or one of the other performance statistics.

    From Cruiser
  • Measure the performance of your application itself with the new and old servers. It's not necessarily easy:

    • Set up a performance test environment with your application on (depending on your architecture this may consist of several machines, some of which may be able to be VMs, but some of which may not be)
    • Create "driver" program(s) which give the application simulated work to do
    • Run batches of work under the same conditions - remember to reboot the database server between runs to nullify effects of caching (Otherwise your 2nd and subsequent runs will probably be amazingly fast)

    Ensure that the performance test environment has enough hardware machines in to be able to load the database heavily - this may mean swapping out some VMs for real hardware.

    Remember to use production-grade hardware in your performance test environment - even if it is expensive.

    Our database performance test cluster contains six hardware machines, several of which are production-grade, one of which contains an expensive storage array. We also have about a dozen VMs on a 7th simulating other parts of the service.

    From MarkR

Where should assets go in a code igniter project?

I'm just starting with CI, and am not sure where things such as css, js, images should go.

Outside the whole system folder seems ok, but that means everything is seperate. Inside mean s the filepaths are longer and I'm worried that it might mess things up.

What's the official line on this?

  • I usually put separate folders at the root level, so I end up with a directory structure like this:

    /system
    /css
    /js
    /img
    

    Seems to work for me - when you use site_url(url), the URL it generates is from the root, so you can use site_url('css/file.css') to generate URLs to your stylesheets etc.

    Rich Bradshaw : Ah, that makes sense. I wanted to be able to use site_url, so this makes sense. Thanks!
  • I hate having so many directories at the root level, so I use /public and use htaccess to rewrite /scripts to /public/scripts and so on.

  • I find it best to keep the assets on the root level. You can use <?=base_url()?> to echo the full root of the site. In the config file, you set up the root of the website. This statement just echoes that out.

    Because of this, you can use includes like this:

    <link href="<?=base_url()?>/css/style.css" rel="stylesheet" type="text/css" />
    

    anywhere in your code, and it will still get http://example.com/css/style.css.

  • There's a article/FAQ that discusses this in CI's wiki. It seems a good way to setup you application.

    From Clutch
  • thank u so much for this solution i am bothering about base url now you have provided me best solution thanks for it

    From hamza khan
  • base_url()/css/name.css

    Mitchell McKenna : base_url() actually includes the trailing slash so you'd want: base_url() . 'css/name.css';
    Tejas1810 : ok.ok.thanks .i know but i m forgot to put it
    From Tejas1810

Determining when an EDGE connection comes back after a dropout on an iPhone

I've incorporated Apple's Reachability sample into my own project so I know whether or not I have a network connection - if I don't have a network connection, I don't bother sending out and requests. I decided to go with the status notification implementation because it seemed easier to have the reachablity updated in the background and have the current results available immediately as opposed to kicking off a synchronous request whenever I want to make a network connection.

My problem is that I start getting false negatives when on an EDGE network - the phone has connectivity, but the app thinks this isn't the case. My understanding is you don't get a notification when an EDGE connection, so my assumption is that I lost and regained the connection at some point. Restarting the app is usually sufficient to see the network connection.

This isn't an optimal solution, so I was wondering if anybody else came across this problem and had any thoughts on a solutions.

(I don't know whether this applies to 3G as well; I'm running a first gen iPhone).

  • Reachability notificataions didn't seem to be reliable for me either, for detecting Wi-Fi. So I just use polling instead. Checking every 5 seconds seems to do no harm.

    - (void) checkReachability {
        BOOL connected = ([[Reachability sharedReachability] localWiFiConnectionStatus] == ReachableViaWiFiNetwork);
    
        // Do something...
    
        [self performSelector:@selector(checkReachability) withObject:nil afterDelay:5.0];
    }
    
    Robert Gould : Thanks I was planning on incorporating Reachability today, so you probably saved my future self some time :)
    Rahul Vyas : hey how do i use this class.I added Reachability.h and Reachability.m file and importedreachability.h file in my appDelegate now when i put your method in my appDelegate i get errors.
    Chris Lundie : The Reachability code has changed significantly in the past year. So, the above code will not work anymore.