Friday, February 8, 2013

The missing Javascript prototypes.

Javascript is missing some prototypes, and so is jQuery.
The following relate to strings, and are heavily inspired by Java methods. This is what I use to trim strings and clean strings of HTML entities.
String.prototype.othertrim = function() {
    return this.replace(/^\s+|\s+$/g, "");
};
String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
String.prototype.fulltrim=function(){
    return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');
};
String.prototype.replaceHtmlEntites = function() {
    var s = this;
    var translate_re = /&(nbsp|amp|quot|lt|gt);/g;
    var translate={"nbsp":" ","amp":"&","quot":"\"","lt":"<","gt":">"};
    return(s.replace(translate_re, function(match, entity) {
        return(translate[entity]);
    }) );
};
These are for jQuery. The first is a POST method that is similar to $.getJSON. The other tells you if a tag exists. You can then do a $('#tagcheck').exists(); and it will return 0 if the tag is not present.
$.postJSON = function (url, data, callback) {
   $.post(url, data, callback, "json");
};
jQuery.fn.exists = function(){return this.length>0;}

Thursday, February 7, 2013

MacOS 10.8 is terrible

Well, so much for improvements in software. This chat log pretty much sums up the state of MacOS these days.
Robert:  and i'm having a problem

me:  okay
what's not in the path? git?
do a "where git"

Robert:  when i try to download get
git - it says it cant open it bcause it is from an unidentified developer
note this is on my mac

me: ah?
I disabled that at some point.

Robert:  how do i disable that

me:  Security & Privacy in preference

Robert:  that did it
i just did the right click open thing
so much for not needing right click in mac
the only thing OS X 10.8 has going for it is that Windows ME and Vista were produced.
without those attrocities i would list it as worst OS upgrade ever.

Monday, February 4, 2013

Language unite disparate groups.

Language unites people.
This is why the Japanese forced the Tokyo dialect on everyone.
This is why the communist Chinese forced Mandarin on everyone. (even if Mandarin is not Han)
The American's force nothing upon anyone linguistically. I speak English, and I am fine in the USA as long as the person who wants to interact with me speaks English. I have found that I do not like black English, because it is expected that I understand it. I do not understand it, so I did some research into it. Formally, called African American Vernacular English, I strongly question the value of the study or use of this type of speech as a language unless it is also spoken concurrently with proper English. "Proper", of couse, is relative; however, my interactions with AAVE have been based around harassing the listener, and I do not feel that I need to accommodate those who chose to force something upon me. I would much rather try to hash it out with someone in Spanish.

Saturday, February 2, 2013

Space Shuttles

I very much like space, and the idea of space travel. All-in-all, the Americans have done very well. I have tried to watch all of the space launches and re-entries.

On the 10th anniversary of the Columbia breaking up, I remember watching it. I will never forget that night in 片町 because I convinced the bar master to turn the TV to the NASA feed instead of football, and then the whole bar watched it burn up. This was terrible, but substantially better than the only time that I got to see a launch live, ST-51-L.

The list of heros who risk it all and lose gets longer, but I want to thank:
"Gus" Grissom
Edward H. White
Roger B. Chaffee
Greg Jarvis
Christa McAuliffe
Ronald McNair
Ellison Onizuka
Judith Resnik
Michael J. Smith
Dick Scobee
Rick D. Husband
William C. McCool
Michael P. Anderson
Kalpana Chawla
David M. Brown
Laurel Clark
Ilan Ramon

...and all those who wish to touch the stars.

Thursday, January 24, 2013

I can make a nuclear bomb.

I can make a nuclear bomb. However, "can" is loosely defined here, because I am knowledgable but not able. I do not have the desire or materials, but they are really simple devices. When countries, such as Iran and North Korea, cannot make them with pooled resources, I wonder what is wrong with them.

Some background:
Special Relativity was published in 1905.
General Relativity was published in 1916.
Now, let's put ourselves in 1945 with a slide rule. We have two types of bombs that we can make: uranium (such as Little Boy), or Plutonium (such as Fat Man). If I had to pick one, I would pick a the "gun based" Little Boy. This takes a lot of Uranium, and is inefficient, but it's pretty much fool proof. If you look at the mathematics for this weapon, it's obvious why you'd make it this way. You can pretty much guarantee that it will work, you wouldn't even need to test it. Now it comes down to what you need to do it, which is either whole bunch of centrifuges or a lot of time.

Using ore that is readily available (the earth is a fissile system, there's tons of Uranium about), and a single centrifuge (I designed one on the back of the piece of paper, it might work) at the cost of about ¥20,000,000, I would take me about 300 years to get enough U-235, so the limiting factor is the number of centrifuges and the cost of power.

So in summary, anyone can make a bomb easily. I definitely believe that nuclear power is a more noble cause because it is free. You take a hot rock, remove energy and put it back in the ground where you got it. If you think that nuclear power is a terrible idea, well, frankly, you are an idiot. Here's radioactive coal ash for the layman. --Dr. Suigin, Ph.D. (no, I'm not kidding)

Wednesday, January 23, 2013

The Ramen Girl

Last night, I saw The Ramen Girl, which is must say was very good. I tend to like movies with Japanese language in them because I get both sides of the story, which lends to a bit of a paradox. In English, it really is a terrible movie. I would give it 2 of 5 stars in English; however, I would give it 5 of 5 if you understand both Japanese and English. There is basically no way for someone without Japanese language to understand the nuances of the movie. The Japanese script is wonderful, and the interactions of the Japanese are lost in the English translation. I thoroughly enjoyed the movie, but most would not.

Sunday, January 13, 2013

Jerry Springer is class!

Well, Jerry Springer is not *exactly* class; however, this is pretty humbling:
"I am the father of the destruction of Western civilization" -- Jerry Springer
That quote is from a video that is here.

Jerry was the Mayor of Cincinnati but then had to leave politics when it was found that he paid for a prostitute with a cheque. The best part is that he admitted it. I have never heard of a politician admitting anything. I think that is pretty interesting.