Mastodon Politics, Power, and Science

Monday, May 26, 2014

First Ruby on Rails Application.

The first thing you need to do is to make sure you have everything installed on your Linux box.  On my older Ubuntu box this involved running the command:
sudo apt-get install ruby rails sqlite3 libsqlite3-rails 
Then I ran the following commands:
mkdir RubyOnRailsApps
cd RubyOnRailsApps
rails FirstApp
cd FirstApp/
./script/generate controller Say
vi app/controllers/say_controller.rb 
  And make the file look like:  
  class SayController < ApplicationController
    def hello   

    end
  end
vi app/views/say/hello.rhtml
  And make the file look like: 
  
    <html>
     <head>      
       <title> First Ruby On Rails App! </title>    
     </head>    
     <body>      
       Hello World!    
     </body>  
  </html>
Finally, start the server like this:
./script/server 
Then type this into your web browser:
 http://localhost:3000
And you should see the following;




Thursday, May 22, 2014

Why your browser should never actually directly download anything.

One of the reasons that application programming is so difficult is that the application is only provided very low level operating system calls to do most tasks.  This means that every application must reinvent the wheel when they do common, every day tasks that nearly every application does.  If you download 20 browsers you just downloaded 20 ways to cache files, 20 ways to handle bookmarks, 20 ways to download files, 20 ways to read and present a limited set of file formats and on and on.

There needs to be an application layer between the application and the operating system. The application should have no direct contact with the operating system.  Everything it does should be mediated by this middle layer.  

For instance, let's say you are writing a browser.  You have a text box for someone to type a Uniform Resource Locator (URL), and you have a button that you press to execute that query. In current browsers you would have to parse the URL, see if you know how to handle all the parts, and then make the network calls needed to get the requested file from the server.  You would have to assemble all the packets and parse the data all yourself.  If you got an image file, you would have to have a library to support that image format. If there is a caching system you would have to handle all that as well.  When the response comes back  you have to parse that as well, and then display it.  Often there will be multiple additional requests to complete.  Eventually the page will be done and displayed to the user.

A better way would be to just pass the request down untouched to an application layer that handles those requests, then handle the error, or pass the proper return value to a presentation element.  This can be a plug-able system where components can be updated and configured, independent of the browser.  The files returned to the system will be of specified formats.  These formats will also be plug-able and configurable and new media types can be added easily at the application layer.  These files will be properly parsed and verified by the application layer and handed back to the application to be handed right off the to the display portion of the browser application.

You remember how IE on Windows couldn't handle PNG files for like a decade?  And how they still don't handle SVG files? Well, with this new way of handling application building that kind of limitation will be a thing of the past. On this hypothetical system there will be just one way of handling a file format, and that one way will be heavily tested.  Any new flaws will be added to the test, and then fixed, and the tests all ran again to make sure the fix didn't break anything.  No values in a format will be believed without verification.  

There will be a single caching system for downloaded files and anything that wants cached files will share the cache.  The caching system will also act as a file down loader for other apps.    The same thing for bookmarks, and playing videos, and displaying images.

But here is where things will get interesting, instead doing it just one way, you should be able to install new modules that handle downloads and configure your system to use the new improved download manager that would handle file downloads better not just for a single browser, but for every file download on the system, every browser, every file manager.

The same thing should happen for every file format: images, video, audio, and media containers.  This means that the same media player and embedded media players will be expandable for decades just by adding new small format objects that are small and very limited in operation.  Their functionality can be severely limited by the system to only acting on streams of data.

These small files can be independently tested and such a system can be made much more secure than today's huge all in one applications.  Any updates needed to a format can be done quickly and easily and no reboot needed.  Because of the plug-able format handling it will be easy to integration test the complete system.  

This means that the browser itself would be much simpler, and just request support from the application layer/OS  to handle file downloads, presentation, and all file formats.  This means that browsers will also become very easy to write and test.   This also means that finally the browser features will fuzz into every application on a system, and make writing any sort of application easier.  Imagine downloading the latest web browser for a system, and it is only 100K of code.   Imagine a file manager that is only 10K. It would be possible to completely test such small applications.

So, having a real application layer that handles 90% of a typical applications behavior, in a plug-able way would make everything smaller, more easily testable/secure, and up-gradable in ways that today's applications are not.  

Wednesday, May 7, 2014

Just Graduated from College.

College later in life is an interesting experience.  I had not finished my Computer Science degree in my 20's because I got a job before I graduated and rapidly moved up in my career.  For over a decade not having a degree actually made more more employable in finding computer jobs than having a degree.

Having worked programming and administering computer networks from the time I was 25 until my mid 40's, I found that I had suddenly become unemployable after the economic crisis of October 2008. I worked at a variety of small odd jobs, basically taking anything that anyone offered to me during this phase.  One of the main reasons I was told that I could no longer get a computer job is because it was easy for HR to do a quick scan of resumes and just toss any that didn't have at least a 4 year degree.

After working an assembly line job for a year I decided that I needed to do whatever it took to get back to working with computers again. So I quit my job and signed up for classes that were just beginning at the local tech school.  Coming back to school after having worked jobs for so many years made school very easy the second time.  It also helped that I am years past distractions like dating or drinking.  The only thing that was tougher than a job was having so many different classes at the same time, each one totally unrelated to the others.

I took all my prerequisites and got associate degrees in both General Science and Liberal Arts Transfer at the community college. Because my grades were so good I was able to be accepted into Phi Theta Kappa, and because of that I got a scholarship at a fairly prestigious local private college.

In two years I earned a Bachelor of Science in Information Systems along with minors in Mathematics and Philosophy.  I knew that I would not get A's in Mathematics, so that I would be giving up my Latin "with highest honors."  I made the conscious decision to learn more than was required even though I knew that it would negatively impact my final GPA.  I ended up with an overall GPA of 3.855, which I am happy with but it put me short of the highest honors by 0.045, because of two B's and an A- in mathematics courses.

This is something that grades really don't reflect, because an A in an easy introduction course is worth as much as an A in a high level advanced course in calculating GPA.  So someone that challenges themselves may look worse on their GPA despite having gained a more well rounded education.  I really don't know how employers can judge this except on a case by case basis.  It is a shame that nobody has come up with a standard system to evaluate how difficult classes are so that more advanced classes are worth more and to rate people higher that take a variety of courses from many disciplines.

Now that I have graduated I am beginning to look for a job.  This is still a total mess. There is no standard XML format to submit resumes to employers.  Such a format combined with a few simple editor tools would make it very easy for a person looking for a job to create a comprehensive resume in a standard XML format, easily submit the resulting resume.xml file to multiple job search and company websites, and for employers to automatically do a rapid match against the requirements for every job opening they have.  As the XML was being processed by the company additional fields could be added to the XML as interviewers rate

Such a format could even easily be presented in a variety of ways that emphasis different aspects for a specific company, if you were printing out a specific resume to more exactly match an old fashioned employer that can't accept data in the information age.


Friday, April 25, 2014

The Crank-Nicolson Method for finite-difference of Parabolic Problems.

This is the last section we covered in Numerical Analysis class.

This is the heat distribution over time of a thin heated rod along the x-axis.  The approximation works by taking evenly spaced points along the length of the rod, over the time-axis.

The code is here:  Parabolic_FinDiff_Final02.c
Using this library: matrix.c  matrix.h

Compiled with the following command:
gcc  matrix.c Parabolic_FinDiff_Final02.c -lm -o prog02
The problem required that the step spacing along the x-axis be .2 and once that was working I tried .1, then .01 which works with 400x400 matrices and 400x1 vectors. At .2 and .1 the program ran in about 25ms.  At .01 step size the program took 9 seconds to write the results to a file.  Running the program at .002, which works with 2000x2000 matrices takes 18 minutes and 43 seconds and takes up 9% of system memory.

I am currently running  at .001 step size which will create 4000x4000 matrices to see if that breaks my matrix library. This only took 4 hours to run.  At a matrix size of 4000, the program takes up 36% of system memory.

Step, estimated result, and actual results.
Last section of results at .01 step size.




Wednesday, April 23, 2014

I destroyed a friend's thumb drive tonight.

In class a friend gave me a thumb drive so I could edit a file, because the email system hadn't sent an email to me after 20 minutes despite us sitting 5 feet from each other.  The huge cases are mounted flush with the front of the desks and the place where you plug the thumb drive in is right at the front center, middle of the case.  I was in editing and he asked me to look at something and I rolled my chair over about a foot and broke the thumb drive connector about 90% off, just thin bit of metal on one side was holding it and ground, d+, d-, and power pins were all ripped right off the board.

Since there is just 2 days before finals begins, of course he has projects due and his only copy is on the thumb drive.  I felt so horrible, like a total clumsy oaf.  But I am good with electronics and the board wasn't cracked, so I thought I had a good shot at recovering the information.

I took all the parts home. Put together my solder station, scrapped that tough green stuff they put on the mother board traces in 4 spots.  The power connection was the weak one, it came up through the board from underneath and only had a tiny little spot left to connect to.  It ended up looking like this:

Thumb drive with connector mostly ripped off
and 4 wires soldered in place.

I checked for continuity a dozen times, using 2 different meters, paranoid that I was going to short out something and blow the whole thing up. Just what I needed to do.  Not bad enough to destroy the drive, but I had to fry it as well.  I would have felt really bad if that happened.

But when I plugged it in the LED turned on, started flashing and the folder popped up.  I quickly made a copy of the drive to the hard drive.  And an hour after that the power wire popped loose when I handled the drive just a little bit. :D

Emailing my friend the files he needs tonight, and will hand him another thumb drive with everything saved in the morning.  I feel better now, even though I am a clumsy oaf, at least I am good with fixing electronic things, at least long enough to save the data.

I found a better point on the back to solder the power connector.  I think if I had some more hacker putty I could encase this whole thing and keep it working for good.

Tuesday, April 22, 2014

Partial Differential equations


Last homework for the class.  Just have a test left. :D
PartDiffEq.c       -  Example from book 
PartDiffEq_HW1.c    -   Problem 1 from handout.
Really bad picture, until I scan in the page, problem 1 layout and actual results

Obligatory use of my matrix library:
matrix.c  matrix.h
Compile like this:
gcc  matrix.c PartDiffEq_HW1.c -lm 
Save the results to a text file:
./a.out  > PartDiffEq.results.txt
Not sure I have this down pat yet.  When the equation is not equal to 0, I am not sure what to do, the HW1 I had a formula to get the exact answer, and I calculated back to figure out what to subtract from the output vector to compensate for that.

What we used the formula for was to find the temperature of an insulated thin rectangular plate that had reached a stable temperature. You have to figure out the formula for the temperature of the edges, make a grid of points inside and create a matrix for the points, then create a vector of the outputs, find the inverse of the matrix and then calculate the solution vector.


Sunday, April 20, 2014

Why the military tribunals should scare the hell out of us all.

I promised politics with this blog, so here I go.

Over the centuries governments were always held to a just standard in the ways they dispensed justice by the people that system represented.  Even serfs were only treated so badly by their lords, and the lords had responsibilities that they were held to in protecting and feeding their subjects.  And too capricious dispensing of cruel punishments could result in his own people dispensing the same justice back on a lord.   So in order to game the system the wise power brokers realized that they need to turn the public against who they desired to throw down before they moved against those people.

Politicians have always been good at reducing their enemies from human beings to some lesser outsiders that are not as deserving of justice as we good people are.  Strangely these evil people always seemed to have possessions that the politicians and their powerful friends coveted. In ancient Greece the charge was corruption of the youth.  In the middle ages it was the Inquisition.  Just before and during WWII it was the final solution.  In the 50's just being accused of being a communist was enough to destroy a person.   And today it is terrorism.  The common thread in all these atrocities is that the mere accusation of a crime is all that is required.  The accusation reclassifies the accused from a human being to something lesser.  Only then are their rights and possessions stripped from them.

In a just system the accused has the right to a fair trial with an impartial jury.  They have the right to mount a defense and there is a presumption of innocence.  Often during a trial the accused is free on bond while they organize a defense and clear up their personal affairs.  Only if there is a conviction of a crime is the person stripped of their rights and only to the extent that is required for their rehabilitation back into the mainstream of society.  

These military tribunals that began under Bush, and continue under Obama, are solely to be used to convict "terrorists." Who is a terrorist?  Why anyone the American government accuses of being a terrorist. Certainly terrorists are all guilty of the crime of terrorism, that is just assumed, otherwise why would the government accuse them?  So because they are guilty already we can hold them in inhumane conditions and treat them as less than human.  We can torture them and force confessions from them.  Just as witches confessed to consorting with demons during the the Inquisition. These kangaroo courts reduce the rights ahead of the crime, eliminating the presumption of innocence based on an arbitrary designation of terrorist being assigned to a human being.   This reclassification from human being to something lesser precedes the automatic assumption of guilt. 

Make no mistake, being a terrorist is something that any of us can be _accused_ of being at will by anyone in the government. But they would never accuse Americans of being terrorists and take their rights away without a trial, you say. 

Like the right to life?  http://www.cbsnews.com/news/who-were-the-4-us-citizens-killed-in-drone-strikes/  

How about the right of liberty? http://www.theguardian.com/world/2011/dec/15/americans-face-guantanamo-detention-obama   

How about the right to travel?  https://www.aclu.org/national-security/federal-court-sides-aclu-no-fly-list-lawsuit  

How about the right to own things? http://www.cato.org/events/policing-profit-abuse-civil-asset-forfeiture

Surely they would only target the criminals?  It amazes me how people that don't trust the government to pour piss out of a boot with the instructions on the heel will trust the government to know who a criminal is 100% of the time. 

No, you cannot trust the government to do anything right.  The government is as good at accusing people of crimes as they are at balancing the budget. Or in other words, horribly bad at it.  That is why we have courts and juries and appeals. Because the government gets things wrong in a surprisingly high number of court cases. 

We need to end the travesty of the Military Tribunals.  We need to allow the human beings that are accused of terrorism the same rights that you and I expect if we were accused of a crime.  Or when we are finally accused then we will find out that we have no more rights than those we allowed to be persecuted before us in our names.

The Shape Behind the Infinities: Renormalization as Slope Extraction and the Anti-Geometric Axiom

J. Rogers, SE Ohio Abstract The infinities of quantum electrodynamics are the unbounded growth of the 1/r profile toward small scales, the s...