While working on a ruby rails project, i stumbled in the following problem. I was trying to create a scaffold for a model (a ruby class representing a row in a DB table). I used the following code:
#script/generate scaffold incident_reported
incident_reported –> is the name of my model
Ruby rails framework makes certain assumptions based on the model name you provide. So in the above example it assumes that my table in the DB is named ‘incident_reporteds’, which of course was wrong. The error i got for running the above script was:
error Before updating scaffolding from new DB schema, try creating a table for your model (IncidentReported)
As a result of the error no *.rhtml templates were produced, which of course was frustrating. I could ignore this and simply create the *.rhtml templates myself. All i had to do was add the following line into my model’s class:
and simply write the *.rhtml files by hand.
Many thanks to Gregory Seidman for the solution he provided me in rail’s mailing list. Here it is:
Toward the end of your config/environment.rb there should be a commented
out section on inflections. You want something like this:
<span class="moz-txt-tag">|</span>inflect<span class="moz-txt-tag">|</span>
inflect.irregular ‘incident_reported’, ‘incidents_reported’
I have tested it and it works just fine 🙂
I have found a nice tool called cmake which can create a makefile for you given the source code directory of your project. It seems to be quite configurable. So if you were always troubled about how are you going to create the makefile for linux, you don’t have to worry any more.
This tool can also go the other way around. Given the source code it can create the solution project (*.sln) for your visual studio .net environment.
I will try it on some of my projects and see how it goes.
Keep coding 🙂
I have been trying recently to create a simple installer using Visual Studio .Net 7.1 setup project.
All i needed my installer to do was to run a simple program from a shell. I didn’t need any program folders, registry keys and of course no entry into the Add Remove programs. Such thing is simply impossible! I ended up creating a dummy installer class, to use it as a custom action during install. What i did in that installer class was simply to throw an InstallException so that the installation rolls back and thus not getting the entry of my installation into Add Remove programs.
Next problem was that i didn’t want the user to know about this intended failure. I tried to play with the installers gui but things there are sort of ‘hardcoded’ so you can’t change the messages of your installer’s Finish screen. One sollution that came to me was to erase all dialogs (since i required no input from the user during installation).
All the above was quite a mess for a simple almost do-nothing installer. Among other things, due to the use of the installer class i created, the user of the installer was also required to have the .Net Framework 1.1 on his system!!!
Finally i used Inno Setup and everything was ready in minutes. In specific the functionality in wanted (no entry in Add Remove programs) was simply one checkbox.
What a mess…
Here we go again with another usefull piece of code. The following code is for determining if the user that runs your application belongs to a specific group. In the following example i check if the user belongs to group ‘Administrators’
The following code applies in Namespace System.Security.Principal
Dim user As WindowsIdentity
user = WindowsIdentity.GetCurrent()
Dim principal As New WindowsPrincipal(user)
If Not principal.IsInRole(“BUILTIN\Administrators”)
MsgBox(“Sorry you have to be an administrator”)
Ok that’s it. In VB .Net 2005 there is the My.User object which provides such functionality, so there is no need to do the above.
Happy coding 🙂
Ok i know it’s a big title … but it describes the problem.
Lets say that you have a C++ class and you wrap it using swig. Now you decide to inject some code of your own into the constructor wrapper. If you try defining a typemap(out) you will not succeed. Instead the way to do it is this:
Β #include “MyClass.h”
%feature(“ref”) MyClass ” Here between the quotes add your code ”
Well that’s it. Let me note, in case you are not aware, that the above code should go inside the *.i file that will be parsed by swig. You have now managed adding extra code into the _wrap_new_MyClass function that wraps the costructor of your class. Keep in mind that the above solution goes if you are targeting Ruby. Perhaps for other scripting languages you can add code into contructor wrapper function using %typemap(out) MyClass*, but that doesn’t work for Ruby. The above case is valid for swigwin-1.3.27 that i use currently.
If you need badly to use LoadResData in .Net VB you will have to use the VisualBasic.Compatibility namespace. This also applies to otherΒ VB6 functions that areΒ notΒ supported in .Net VB any more.
First of all right clickΒ onΒ your project in the solution explorer pane. Choose add reference and in the tab named .NET choose the ‘Microsoft Visual Basic .Net Compatibility’ and press select button. Then press ok.
Now write Microsoft.VisualBasic.Compatibility.VB6.LoadResData (…) and do whatever you want. If you don’t want to constantly write all the above extremely long line you can go to your project’s properties, select Common Properties->imports on the left window and add the namespace Microsoft.VisualBasic.Compatibility.VB6 into your project. After that you can directly write LoadResData(…)
Ok. Firebolt is ready again for major changes. Next releaseΒ willΒ be 0.3v which will not be refactored dramatically again (lets hope). It has been a little unpleasant geting breaking changes with each new release.
EasySockets is the new feature as you already know. It is a simple mini socket api. It is asynchronous in receiving data. It is synchronous in sending. It also supports sending packets. So if you tryΒ to send a packet of 1K size then the other socket will receive an OnRead event with exactly 1K size of data. This is not quaranteed by the Tcp/ip protocol, since it is a stream protocol. If you send 1K data using tcp/ip it is not quaranteed that the receiver will get it all with one recv() and not in 3 or more portions of various sizes.
Thus after a lot of troubles Firebolt 0.3v will beΒ even more robust and reliable.
Here is a usefull link for all those who make deployment (setup) projects using visual studio.
It is a list of properties that can be used for Launch conditions.
Based on the above info i will give you an example.Β If you want to create an installer that only the administrator will execute, you can create a launch condition and in it’s property ‘Condition’ place ”AdminUser” (without the quotes). If you read the above link you will know that AdminUser is true if the current user executing the installer is an administrator. If this condition fails then a dialog box appears containing the error message that you provided in the property Message.
Soon i will also host Firebolt’s page here, since sourceforge doesn’t provide dynamic web pages.
Wellcome websurfer. What brought you here? Speak your mind. Hehe just kidding… This is my very recent homepage so enjoy. I try udpate things as soon as i can.