Wednesday, December 8, 2010
Word 2010 is begining to grow on me
Saturday, November 27, 2010
Sunday, November 21, 2010
Div Overlays
Eos ea eros paulo dolore. Commune recusabo ad mei, sea justo soleat scaevola ex. Te impetus scripserit theophrastus sed. At mel nostro cotidieque, cum et exerci aliquando. Eos ex nemore officiis moderatius, te quo natum nusquam reprehendunt. Duo et consul semper, probo animal has ne.
Pertinax tractatos repudiandae mei ei, et conceptam constituto nec. Veritus alienum pertinax mei cu. Assum iudico albucius eu sit. At mea fugit vulputate, vix legimus tibique corpora ut. Te usu debet expetendis, id falli consectetuer vim. Alia sonet eloquentiam sea ex, sed te illum corpora ancillae, id pro suavitate ullamcorper.
Wednesday, November 17, 2010
Modal Windows
Sunday, November 7, 2010
Moving Columns in MySQL
Move a column after some other column
mysql> ALTER TABLE mytable MODIFY COLUMN mycolumn INT AFTER someothercolumn;
Move a column to the first position
mysql> ALTER TABLE mytable MODIFY COLUMN mycolumn INT FIRST;
Thanks to Masao Kitamura
Saturday, October 2, 2010
Sunday, September 26, 2010
Get it into the hands of the people
Monday, September 6, 2010
User control in WinXP
Sunday, August 1, 2010
Connections with MySQL
The best way I found to get around this problem when using MySQL is to just connect and dis-connect after each transaction with the database. It may cause a small performance hit, but it improves the stability of the application.
Tuesday, July 13, 2010
Saturday, June 26, 2010
MathML for Publishing Math on the Web
Wednesday, June 23, 2010
Buildings and Earthquakes
So, my wife, 5 stories up, felt more tremors then I did at ground level. That meant that the building she was in amplified the tremor to a level that it was noticeable, while environment did not do any amplification because I was on ground level.
Does that mean that we are designing buildings that amplify the vibrations experienced by earthquakes? The higher up in a building, the more potential for damage there is due to buildings collapsing. Are we exasperating this danger by designing buildings with certain mass/stiffness characteristics that increase the changes of vibration and the subsequent damage?
Wednesday, June 9, 2010
Astronomy and the nature of God
Does the character of the heavens reflect the character of their creator? If we allow ourselves to imagine just for a moment that there might be a divine creator of the universe, what would the universe tell us, if anything, about the character of that divine creator or upholder or purpose behind it? As an astronomer, I thought about that to some length and I came up with this little list of my own. You might come with you own thoughts as well, so this is not anybody's definitive list: it's what came to my mind viewing this question.
From astronomical observations and the resulting inference, within this view of considering a divine creator a possibility - then this God, this creator, would appear to me to be very powerful: we've seen already some of the astronomical objects and forces that are powerful.
Creative: a creator and a lover of beauty.
We've seen the beauty of galaxies and nebulae and stars, and most interesting to me is the connection between that beauty and us, being creatures here within this universe, who can recognize that beauty. I'm told that our brains are hard-wired to recognize design and beauty, and I think that there's purpose in that.
Patience: there are 13.7 billion years of history of the universe, as we can best guess right now. Now, this God would have a different view of time and efficiency than we have. We would gauge things by our life spans. But if that's not the important feature for this God, then this God would appear to us to be patient, allowing things to unfold according to processes that are needed to create the conditions that eventually would lead to life.
Faithfulness: allowing these fundamental physical laws of the universe, of gravitation, and of time moving forward. These kinds of things don't jump around and change from moment to moment, so this allows for the ordered development of the universe according to these fundamental physical laws.
And yet whithin this context of faithfulness, we see a desire for freedom, because there are elements of our universe set up that allow for freedom. We have things such as chaos theory, quantum theory, and so forth, that allow a sense of freedom within this ordered context. I believe that that's related to perhaps our ability in our experiential sense to understand that there really are such things as pain, and choices, and good and evil.
And we obviously see that our universe enables life, so this God would be one who gives and enables life, and enables a fruitful universe. We're here; there may be life elsewhere, as well.
And then, I would call this love: that we are enabled to investigate, appreciate, and also understand the magnificent cosmos of which we are a part, as we are seeing more and more of what's out there.
Friday, June 4, 2010
Moral Clarity: Do Morals Make Sense?
Susan Neiman's Moral Clarity looks at both of these extreme. It advocates against the Greek philosophers view that in the end it always turns out best for the moral person by showing that we live in an unjust world where you can never be guaranteed that moral activity will be rewarded. It also challenges the religious viewpoint by questioning why we need to look to the after life for motivation for moral activity today.
Rather than supporting either of these views, she argues that we have an intrinsic morality in us - it is part of what makes us human. By tuning into that inner morality and living consistent with it, our human struggle can make sense. Living with high moral standards may never result in success, comfort, or pleasure, but it can enable our lives to have purpose.
I remember hearing a story of one of the worst forms of torture in German Concentration camps. There would be a pile of bricks at one end of the yard. The workers would have to cart the bricks from the one pile to a new pile on the other end of the yard. The next day, they would have to cart the brick from the second pile back to the first pile. They would back and forth like this day after day. Their tasks were utterly meaningless. After a few days of doing this, people would start to go crazy and some would commit suicide. It is not in our nature as humans to be able to continue to exist in meaningless activity. Our lives need to make sense. Our morality needs to make sense, it needs to have meaning for us to continue to struggle to do the right thing when it is so much easier to cast away moral restraint.
Susan Neiman tries to make sense out of morality by showing example after example of people that risk their lives and everything else they hold precious to help another person. The person that risks all they have does not gain anything, they only engage in an opportunity to act constant with a deep moral identity. In that moment, they sense the resonance of their whole being engaged in what it means to be human.
Ivory Towers and Applied Research
Conestoga College has been involved in an applied research initiative with ComDev over the past 2 years, designing automation for one of ComDev's manufacturing lines. SAIT Polytechnic in Calgary partnered with Conematic in developing protoypes and standardized components for an innovative hot water boiler.
These examples are encouraging indications that some of the academic institutions are not stuck in ivory towers. Rather, they are engaging in the real problems of the workplace.
Tuesday, May 4, 2010
Tomcat Database Connection Pool
Check validationQuery.
validationQuery="SELECT 1"
jdbc:mysql://hostname/mydb?autoReconnect=true
Connection Pooling
Connection Reaper class:
JBCD and DBUtils
IBM Discussion on Stale Connections
Handling a Stale Connection
To view the log, go to tomcat6\logs\catalina.out It has all the system.out.println() entries in it.
Thursday, April 22, 2010
Repo 105
1. Company AAA holds some poor quality assets (i.e., sub-prime morgages). AAA's leverage ratio also does not look attractive (it is too deep in debt). It is coming close to the end of a quarter and AAA does not want all that debt and the poor quality assets to show up on it's balance sheet when it issues it's quarterly financial statements.
2. Company BBB offers to buy the poor quality assets from AAA with one of the terms of the contract stipulating that AAA will buy the assets back at a specified date in the future at a reduced price.
3. AAA prepares its end of quarter financial statements. Since the title for the assets is transfered from AAA to BBB, then AAA does not have to record the risky assets on its financial statements. This makes the investors think the company is solid and helps maintain the stock price and rating.
4. After AAA has issued its quarterly financial statements, it buys back the risky assets.
This is what Lehman brother did as it was begining to sink in months coming up to its collapse.
The purpose of financial statements to provide an accurate account of the financial position and health of a company. Such activities clearly oppose the primary purpose of financial statements.
Why are accurate financial statements so important? Because we live in a capitalistic society. One of the tenants of a capitalistic society is that the people who own the capital should be the ones that benefit from the income earned off that capital. Another feature of capitalistic societies is that the person owning the capital is not the person who is actually putting the capital to work. For example, a capitalist my own a factory, but he has other people doing the work of running the factory and doing the labour in the factory.
We didn't alway live in a capitalistic society. Before the industrial revolution, the workers were also the owners of their own business. When the workers are also the owners, there is no motivation for the workers to decieve the owners.
However, when there is a division between ownership of the capital and management of the capital as exists in a capitalistic society, the managers of the capital will always be motivated to hide information from the owners in an attempt to maximize their benefit. In an attempt to curtail this deception, complicated accounting systems such as Sarbanes Oxley and audits are created to try to maintain honesty. It looks like the government needs to add some more complexity to their rules track down the inginuity of the managers of capital.
For more information, see http://www.npr.org/blogs/money/2010/03/repo_105_lehmans_accounting_gi.html
Wednesday, March 31, 2010
Industrial Fan Applications: Pickle Line
The hydrochloric bath gives off acid fumes, so it must be contained in a sealed environment with a negative pressure to ensure acid fumes do not leak out into the environement. To maintain this negative pressure, an industrial fan is used. This fan sucks air out of the hydrocholric bath hood, and through a scrubber to remove the acid out of the air. Idealy, the scrubber removes all the acid from the airstream so that only clean air goes up the stack. Unfortunately, scrubbers are not perfect and occasionally acid is still entrained in the airstream as it enters the fans.
The acid in the airstream is very corrosive on the fan components. For this reason extra precautions must be taken in the choice of fan materials to protect against corrosion. The main areas of conern are the fan casing, fan impeller, and fan shaft.
To ensure the fan casing withstands corrosion, it can be made out of fiberglass with a c-veil to seal the airstream surface of the fibreglass. However, ,one of the concern about using fibreglass is the strength of the casing. Casing strength is considered for three primary reasons. First, the casing must withstand the static pressure differential between the inside and outside of the fan so as not to deflect excessively. Secondly, the aerodynamic turbulence within the fan casing can cause casing vibrations if the casing does not have sufficient stiffness. Thirdly, in the event of a impeller failure, it is good to have a casing that can contain the pieces of the impeller rather than allowing them to pierce through the casing and damage people and equipment. For these reasons, fibreglass casings should only be considered for lower speed fans.
For higher speed fans, the casing can be contructed out of steel and lined with a corrosive resistant barrier. The best barrier is rubber as it does not get damaged easily and during the application of the rubber, the applicator can do spark tests to ensure that a complete seal is obtained. By using a steel housing with rubber lining, the housing has all the strength of the steel with appropriate stiffeners.
The second fan component requiring special consideration is the impeller. For low speed fan applications, it is possible to use a rubber coated impeller. Note that this is only applicable for very slow fans, since the centrifugal forces generated by higher speed fans along with the aerodaynamic forces in the impeller will cause the rubber to be ripped off the impeller. The best solution for the impeller is to not coat the impeller, but rather use a material which can withstand the corrosion while demonstrating suitable mechanical properties. The two primary materials satisfying these requirements are titanium and Alloy C276. Alloy C276 tends to be lower cost then titanium and has a lower corrosion resistance, but is often sufficiently corrosion resistant as long as it is inspected regulary.
The third fan component is the shaft. By using an overhung arrangement, the only component of the shaft potentially exposed to the airstream is the part between the back of the hub and the casing opening. This can be protected by a shaft sleeve that is welded to the back side of the hub and extends through the back side of the casing.
By making special considerations for the casing, impeller, and shaft, an appropriate fan can be designed for an acidic environment.
Tuesday, March 30, 2010
Industrial Fans: Economic Environment
Another area experiencing a boom in demand for industrial fans was the cement industry. In the process of converting lime(calcium carbonate) to calcium oxide, it must be heated. The kiln ID fan draws superheated gas through the kiln and then through a cyclone separator and/or electro-static precipitator. With the boom in global infrastructure development, cement manufacturers were expanding to meet the demand.
The last two years, we have experienced a cooling off in the world wide economic growth triggered by the sub-prime financial crisis. This has resulting on a sharp drop in infrastructure spending resulting in a drop in demand for natural resources.
Fortunately, the economies of the non-western world, which account for the majority of demand for natural resources, did not experiences as sharp a recession as the western countries. This means that demand for natural resources is already starting to pick up again. This can be seen by the Nickel price:
Nickel reached a peak in 2007, and went to a 5 year low in 2009, but now the prices are on the re-bound. This trend is also occurring in many other natural resource prices.
This means that demand for industrial fans should begin to improve in the next 1 to 2 years. During this time of lower demand, fan manufacturers should make use of this time to optimize the management and methods for engineering and manufacturing fans, along with put effort into establishing their market presence. This will enable them to capitalize on the upcoming boom in the fan industry.
Wednesday, March 24, 2010
Using custom domains with Blogger
Fortunately, they have a feature that still enables my blog to be posted at my domain name. Under the publishing part of settings, I am able to specify a unique domain name. In my case I use blog.johnhufnagel.com. The blog.hufnagel.com is set up as a sub-domain of hufnagel.com. I am then able to set up a sub-domain at my domain registrar (which happens to be GoDaddy). Sample instructions for this can be found at How Do I create a cname record for my custom domain
After the subdomain is set-up, it will automatically point to
ghs.google.com
which is the location where the subdomain for the blog is hosted.Thus, the blog is hosted by Google, I get to use my own domain.
Google also provides the options of buying a domain name directly through Google. This is a more straight forward approach if you only want to do blogging on your website. Since there are a lot of other features I wanted on my website, I preferred to have my domain name registered with a conventional hosting company.
Tuesday, March 23, 2010
This blog has moved
This blog is now located at http://blog.johnhufnagel.com/.
You will be automatically redirected in 30 seconds, or you may click here.
For feed subscribers, please update your feed subscriptions to
http://blog.johnhufnagel.com/feeds/posts/default.
Sunday, March 7, 2010
Ethics and Lying
Over the past year I have been reading a lot of authors on ethical theories (you may notice by looking at some of my previous blogs). A lot of ethical theorist discuss lying. I guess lying is a good litmus test for an ethical theory because it challenges the major theories of Utilitarianism (judging the rightness or wrongness of an action based on the amount of utility-or benefit that action causes to the world) and rules based ethics (Deonteology: judging the morality of an action based on the action's adherence to a rule or set of rules)
A classical challenge for the ethics of lying is as follows. During the second world war, Germany was invading Holland. As the Germans soldiers would go from house to house, they would seek out any Jews and kill them. Some dutch people wanted to protect the Jews. Even if they were not Jews themselves, they did not believe it was right to allow the Jews to be killed. These people would hide Jews in their houses. When the German soldiers would come knocking on their front doors asking if there were any Jews in the house, they would lie to them and tell them there are none in the house.
Was it right or wrong for the dutch homeowner to lie about the presence of Jews in their house? Would it have been better for the dutch person to not harbour Jews in their house so they would not be forced to deal with the ethical dilemma of lying? There are certain things we do because of our basic ethical standards (ie: we do not run over elderly people as they cross the road). But there are other things we do that go beyond the basic ethical rules. Some of us go to Haiti to help with disaster relief. Other people help out at the food bank, or spend a bit of extra time with their children in a loving way. These are things that we do above and beyond our basic ethical standards - we would not be considered wrong by society if we did not do them, but because we care (are driven by an internal motivation), we do these things.
The people that harboured Jews in Holland did so because they cared - there was no law saying they had to, not even a socially established norm saying they had to. However, to complete this act of caring, they have to go against a socially accepted ethical standard.
Utilitarians would say that the final result of saving the life of the Jew justified the act of lying.
A deonteologist has a bit more complicated answer. The simple answer is that ethics is based on rules. One of those rules is "do not lie". This would be consistent with Kant's categorical imperative: "Act only according to that maxim whereby you can at the same time will that it should become a universal law." If you just look at issue about lying, then of course you would want it a universal law that people do not lie - otherwise it would be no use having a conversation with someone because you never know when they are telling the truth.
However, if you were to look at a larger maximum of "when faced with a choice between telling the truth and causing a person to die, or lying and saving their life, choose lying", then you could say a larger universal maximum still applies.
However, there is a more complicated answer. The deonteologist also say that there is a ranking system amongst rules. They would probably argue that saying something that would cause someone to die (if the dutch person told the soldier the truth, then the soldier would kill the Jew), is a worse act then lying. Therefore, it is better to do the least harmful act. Now comes the next big questions: how does the ranking system work?
The ranking system would likely go something like this: most important is to protect innocent human life, the next order of importance is upholding rules such as truthfulness etc.
So, you have just observed how lying in a certain context can be justified by the principal ethical theories.
It makes me feel uneasy justifying something I feel is wrong. I grow up learning that lying is wrong. We are trained from an early age to instinctively see it as wrong. Now we look at a situation where it seems that it is the right thing to do. In this type of situation, I would probably act to preseve life, but I wouldn't "feel" right about it. I guess it is not always that easy to do the "right" thing - the idealized perfectly right thing, in an un-ideal, imperfect world.
Wednesday, March 3, 2010
Creating Section Views of Fan Impellers using Solidworks
When creating a section view, the user is asked to draw a line for the section. If the part or assembly is scaled larger then the original line, then the section view is not cutting through the entire section. This can cause errors in the section view meaning that the whole section view has to be re-created.
To ensure that the line defining the section view scales correctly with scaling changes of the part, the section view line has to have relationships with the geometry of the part or assembly. For fan impeller drawings, the best way I found to do this was to snap onto the quadrants of the outside diameter of the impeller when making the line.
Thus the line is defined as going from the top quadrant down to the bottom quadrant. As the impeller is scaled, the line defining the section view is scaled and the section view is maintained.
Tuesday, February 23, 2010
Tuesday, February 16, 2010
Simple Reflection Example
package utils;
import java.lang.reflect.Method;
public class ClassSpy
{
public static void main(String[] args) throws Exception
{
//Specify the class that we will do a reflection on
String className = "utils.SampleClass";
//Create a Class object associated with className
Class toRun = Class.forName(className);
//create an instance of the method which we
will later invoke
Method method = findMethod(toRun, "getId");
//create an instance of the class
SampleClass user = new SampleClass();
user.setId(5);
//invoke the method
int id = (Integer)method.invoke(user);
System.out.println("id "+id);
}
private static Method findMethod(Class clazz,
String functionName) throws Exception
{
Method[] methods = clazz.getMethods();
for (int i=0; i<methods.length; i++)
{
System.out.println(methods[i].getName());
if (methods[i].getName().equals(functionName))
return methods[i];
}
return null;
}
}
The code for sample class is as follows:
Sunday, February 14, 2010
Reading a Class using BLOB from a MySQL Database
public class SampleClass {
static final String DataBase_Url =
"jdbc:mysql://localhost:3306/myDatabase";
static final String Driver = "com.mysql.jdbc.Driver";
//note the Driver will always be the same when
connecting to MySQL but the URL is dependent on
your MySQl database: localhost is the Server Host,
3306 is the port and samptable is the name of the schema
public static void main(String[] args) {
String printStr = "This is your concience speaking.";
System.out.println(printStr);
Connection con = null;
Statement stat = null;
ResultSet rSet = null;
try
{
Class.forName(Driver);
con = DriverManager.getConnection(DataBase_Url,
"username", "secretPassword");
stat = con.createStatement();
rSet = stat.executeQuery("SELECT username from user");
System.out.println("\nUsernames");
while (rSet.next()) {
String ferrariprice = rSet.getString("username");
System.out.println(" " + ferrariprice );
}
}
catch (Exception Exc)
{
Exc.printStackTrace();
System.err.println(Exc.getMessage());
}
finally
{
try
{
rSet.close();
stat.close();
con.close();
}
catch (SQLException sqlExc)
{
sqlExc.printStackTrace();
}
}//end finally
//Pull Blob
stat = null;
rSet = null;
con = null;
//Connection conn = DBUtil.getConnection(connectionName);
try {
Class.forName(Driver);
con =
DriverManager.getConnection(DataBase_Url, "username", "secretPassword");
stat = con.createStatement();
rSet = stat.executeQuery("SELECT * FROM savedcasing");
System.out.println("got rSet");
while (rSet.next()) {
try {
com.faneng.workflow.model.SavedCasingVO
vo = new com.faneng.workflow.model.SavedCasingVO();
vo.setId(rSet.getInt("id"));
vo.setSavedCurveId(rSet.getInt("savedCurveId"));
Blob ib = rSet.getBlob("casingInputVO");
ByteArrayInputStream is = null;
ObjectInputStream ins = null;
if (ib != null) {
is = new ByteArrayInputStream(ib.getBytes(1, (int)
ib.length()));
ins = new ObjectInputStream(is);
vo.setCasingInputVO((CasingInputVO)
ins.readObject());
vo.getCasingInputVO().getDiameter());
}
} catch (Exception e) {
throw new SQLException(e.getMessage());
}
}
}
catch (Exception Exc)
{
Exc.printStackTrace();
System.err.println(Exc.getMessage());
}
finally
{
try
{
rSet.close();
stat.close();
con.close();
}
catch (SQLException sqlExc)
{
sqlExc.printStackTrace();
}
}//end finally
}
}
Monday, February 8, 2010
A good resource for REST web services
Jose's many years of experience in a wide range of Java technologies enable him to explain clearly the required concepts to understand REST while not being excessively wordy on peripheral technologies.
Creating a simple Servlet
When making the servlet in MyEclipse, start a new web project (I called mine ServletExample), then create the package: test, add the HelloServlet class to this package, and change the web.xml as required. Then it should work just fine.
For reference, the HelloServlet class is as follows:
package test;
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class HelloServlet extends HttpServlet {
public void doGet (HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
PrintWriter out = res.getWriter();
out.println("Hello, world!");
out.close();
}
}
The XML file is as follows:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>test.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>
To run the servlet in MyEclipse, right click on the project and select Run-As MyEclipse Server Application.
You can then access the servlet by entering the following in the command line:
http://localhost:8080/ServletExample/hello
Saturday, January 30, 2010
Intelligence from outside intelligencia: Garrett Lisi
Check out his deferential geometry personal wiki notebook. If you scroll down to the section called E8 theory summary, you can click on the formulas and actually edit them right on the screen.
It is always a challenge to show formulas on a web page, and he seems to have figured out how to do it elegantly.
Friday, January 29, 2010
Create a Java Program in Eclipse
I have been doing a bunch of Struts and REST development in Eclipse for which there are good wizards to get started, but it was suprizingly difficult figure out how to build just a simple hello world java project.
With the help of Nathan, I can now do the basic java project:
First, select the new button just below File and open a new Java Project
A New Java Project window will open: enter the name of the project then click Finish
You should now see your project listed in the Package Explorer. Expand the project.
Under the project you will see the project’s package (src) and the library it is referencing. You now want to add a class to the project where you can write your program. So right click the package (src), select new -> class.
The New Java Class window opens. Notice the Source Folder. Type the name of the new class and ensure “public static void main(String[] args)” is selected. Click finish to create the class.
Because we selected the option to create the main, the IDE automatically inserts its declaration into the code. Now we can begin to write our basic program right away.
Replace the comment with this text:
String printStr = "This is your conscience speaking..."; System.out.println(printStr);
In the Package Explorer, right click the class and select Run As to run the program. If a message box appears, select yes to save the project. You will see the text printed to the screen.
Cocktail Jazz for Beginners
https://pianowithjonny.com/piano-lessons/how-to-play-beginner-cocktail-piano-in-3-steps/ https://www.pianogroove.com/jazz-piano-lessons/co...
-
In a regular annotation note, create a stack that looks the way you like. It will take a couple of trial and error attempts since there...
-
I just finished a 1 hour marketing meeting with an organization that I volunteer with. They are trying to create an new website and the look...