Archive for the ‘Uncategorized’ Category

C# arg parser

Monday, December 2nd, 2013

Since I posted a perl one. Note there’s probably some neat way to do this using system libraries that I just don’t know about, but this is what I use

As part of the class (you can have this as a class i.e. Config.cs, or as part of the program:


static readonly Dictionary argsDict = new Dictionary();

Parser:


static public void ArgHandler(string[] args)
{
foreach (string arg in args)
{
Regex quoteRE = new Regex(“\”(.*)\””);
string[] quoteResults = quoteRE.Split(arg);
string workarg;
if (quoteResults.Length > 1)
{
workarg = quoteResults[1];
}
else
{
workarg = arg;
}

Regex argRE = new Regex(“–(.*)=(.*)”);
string[] regResults = argRE.Split(workarg);
if (regResults.Length > 1)
{
Console.WriteLine(string.Format(” — {0} -> {1}”, regResults[1], regResults[2]));
argsDict.Add(regResults[1], regResults[2]);
}
}
}

Get a argument:


static public string GetArg(string arg)
{
string result = null;
argsDict.TryGetValue(arg, out result);
//if (debug)
// Console.WriteLine(“arg ” + arg + ” -> ” + result);
return result;
}

At the top of main(), call:


ArgHandler(args);

From a emailed conversation..

Sunday, December 1st, 2013

TL;DR=We should use prisons as a experimental ground to find out what media help broken people heal

I emailed this, and then – while I think it needs rework and expanding on, which I will probably do later – I thought I should paste it into my blog now just to get it out there. It’s a idea that I’ve discussed with various people over the years, that’s slowly grown..

From email:

This actually reminds me of a experiment I want to do. I will never,ever,ever be allowed to do it, but I think it would be truly awesome.

I want to retrofit a bunch of the country’s jails. I want to equip every cell with a very hardened computer console [as in virtually indestructable and also virtually impossible to break into from a hacking point of view]. Then, I want to try a number of different permutations of libraries of videos and books in each jail, and try different amounts of freedom to roam the net / free phone calls / things of that nature. I’d even want to try in some of the jails letting the employees work doing data entry or other remote-control things and potentailly also try having their income partially go to pay back their victims. I’d try anything in the initial seed set – porn, religious texts, movies from the 20s, childrens movies..

The purpose is to see what set of media, what set of communications options, and what set of employment options

a) Reduce recividism the most
b) Result in the happiest population

If we really think about it, what we really want our jails to do is help the people inside become better citizens. Since we don’t execute very many criminals and we don’t keep very many inside forever, we really want to figure out what to do for them that will turn them into people who don’t commit crimes. Ultimately it’s in the best interest of everyone who has to live here for our jails, rather than “punishing” people – often for crimes they committed because of mental illnesses they have – to heal them. And if a particular set of books or movies or whatever encourages that process, let’s give it to ’em free of charge, maybe even find ways beyond that to encourage them to watch & read! I know from my parking meter days that I could make a terminal that would survive anything a inmate could do to it. It wouldn’t be pretty, and it wouldn’t be possible to touch type on it that easily, but it probably wouldn’t cost *that* much either – and utlimately, if one is measuring using value rather than money, it would potentially pay for itself many, many times over. Plus, the value of knowing which, out of the milions of books and movies we have really heal people is almost beyond putting a dollar amount on.

I also talk about commercial prisons and the profit motive encouraging recidivism here and suggest a fix

I also make another suggestion here – that if we must have commercial prisons we only pay them for the prisoners that do not re-offend.

Me and Gayle’s journey

Wednesday, October 9th, 2013


View Larger Map

My Sprint saga

Friday, September 6th, 2013

So, I’m rather unhappy with Sprint at the moment.

A few weeks ago, during a trip to CA, I somehow cracked the display on my 897 LTE. I didn’t do anything unusually abusive to it, I just set it down on a dresser and it spiderwebbed.

I called sprint, who said they could replace the display/digitizer for $150. Since I know the part is about $100, this sounded reasonable, so I took the device to them for repair.

They attempted a repair, and somehow managed to destroy the motherboard. The phone would just reboot cycle endlessly. They also managed to destroy – beyond any repair, not just filesystem damaged but chip totally useless, a 16G SD card with a bunch of useful data on it.

They gave me a refurbished phone in replacement, and I went about my business.

The first thing I discovered about the refurb phone is the camera wouldn’t focus. This suggested to me that it had been exposed to a transient shock of truly large proportions. The second thing I noticed is that every few days, it would hang in a very unusual way. The heartbeat light would continue to pulse green, but the phone would not respond to the power button.. nor, indeed, any other interrupts (i.e. USB, phone calls, etc). Sadly, the phone has no reset button and has a internal battery, so every time it did this, I had to take it to sprint to be power cycled. The first time, I explained to them that A: It was a refurb and likely had experienced a large G-shock at some point and B: they were not equipped to do component-level repairs on phones, as I saw no hot air guns, no magnefiers, no lights, no DSOs, none of the tools one would need to do such things – hence, they could not possibly fix it, so please give me a replacement. They refused, saying they would only replace it if the failure occured in their shop.

Well, after coming in three times to have it power cycled, they finally admitted, yep, we can’t fix it, yep, it’s broken. However, it would take them 1-2 !weeks! to get a replacement.

I asked about buying a identical device. None in stock. They had two floor models, but it’s against sprint policy to sell those. So I bought a vastly less powerful LG to use while they fix my phone. At retail price because I’m not eligable for a discounted device for another two months.

Now, I’ve been a sprint customer for 12.5 years. However, when my contract expires, I will be finding another wireless service provider. I *know* they all suck. But there has to be one that sucks less than this. Their ‘Total equipment protection’ is useless, because they give you refurb phones that have faults with them! I doubt if Sprint has *anywhere* that’s equipped to do repairs on the tiny surface-mount-and-metal-cans assembly of a modern cell-phone, so what they should do whenever a phone shows up with a reported intermittent fault is recycle it, because there’s no way they can fix it. But instead they send it back out the door to some unsuspecting customer who will then have to figure out A: what’s wrong with it and B: whether they can live with that.

P.S. Motorola, shame on you for not putting a reset button on a device powered by a internal battery. Computers crash. It’s a fact. I will admit that prior to sprint destroying my first 897 LTE it had never crashed in a way that I couldn’t get back from, but that’s still no excuse for doing something so boneheaded.
\

Happy Birthday..

Monday, July 1st, 2013

Happy birthday, 8088!

Windows 2012, IIS 8 shared config, and 0x800f0922

Friday, May 24th, 2013

So, I recently found a fun bug in Windows 2012.

If you are attempting to add features like HTTP Activation, Application Server w/ IIS support, or other web-related features and roles to 2012 and you have shared hosting configuration enabled in IIS, they will fail with the extremely cryptic error code 0x800F0922. What you need to do is DISABLE shared configuration, install your features or roles, and then re-enable shared configuration. The WPI will tell you if you try to install something while shared config is enabled that you can’t do that, but the Add Features / Add Roles bits won’t.

Onair memories

Thursday, May 9th, 2013

When I worked at OnAir, I had a boss who will remain nameless (I’ll call him PHB) because this story is a bit embarrassing for him. We had been sent to PAIX in northern CA to install a Sun enterprise server 1000. After uncrating and racking it, we turned it on and watched as the boot console scrolled through various things, finally ending at a repeated attempt to BOOTP.

Now, at this point, I was all set to sit down at the keyboard and start hacking away at the firmware settings, because obviously the unit had no idea it had a hard drive, much less a operating system. However, PHB was utterly convinced that if we just waited long enough, the thing would boot. Really. Honest. He made me wait a hour, repeatedly telling me not to touch the keyboard.

I went to the hotel room that night and looked up the relevant page of the sun hardware guide. Then, the next day when we returned to the data center, I went straight to the machine, told it to list devices attached to it, then told it where it’s boot disk was. After which, no big surprise, it booted right up.

The thing that really annoyed me was that he wouldn’t listen to me, and I think the problem was, he had no idea what I was saying. Concepts like BOOTP and DHCP and network booting and boot device and whatnot were entirely foreign to him. So, when we got home, I printed out the sun firmware console guide and left a copy on his desk.

People have from time to time done this to me – I remember getting a copy of the Sendmail guide with a post-it saying “see page 53”, for example. I don’t remember ever being upset by it, and neither was he. However, it’s a lot trickier in a interactive face to face setting to figure out, how do I clue this guy in to the fact that he has no idea what I’m talking about and what he’s suggesting is never going to work – I’ve never figured out a really good answer.

I remember when I was at ASP repairing people’s houses, one woman’s water pump got hit by lightning. Now, in fact, all it had done is blown a hole in the metal piece that attached it to the feed pipe, but we didn’t know that. Anyway, we pooled up our ice cream money and bought her a pump (ASP disavowed all knowledge of anything relating to replacing a water pump), dug up her wellhead, and pulled out the old pump. I did some cut&splice&whatnot, and put the new pump where the old one was, and we lowered it back down. Of course, when the pump hit the top of the water, that was the end of lowering.

At this point, I made a suggestion. Let’s turn the power on to the pump, and it will lift water up the column and thereby pull itself down. However, the adults (I was about 16 at the time) decided that was too dangerous and radical, so instead they tried to force the pump into the hole.

Not suprisingly, this was not easy. In addition, grinding the pump’s power wiring against the side of the shaft cut the power wiring, and so once the pump was in place, it didn’t work. We pulled it back out, I patched the cut power wiring, and the second time it was decided we would try my way, which worked. (I bet it’s what all the installers do.)

Again, I don’t know what to do in situations like that. It’s obvious the other person is not in possession of all the facts, but it’s also obvious that they think I’m not either. I don’t want to say things that make them think I think they’re a moron, but I also don’t really want to sit and watch while they demonstrate why their technique is not going to work.

The other question, of course, is how to accept the reverse situation – when someone has to clue me in that my airspeed really shouldn’t be 110 knots at touchdown, or that .net console apps use a connection pool and so it really is okay to throw away a database connection after each query (well, it’s not the most optimized thing in the world to do, but it doesn’t involve reconnecting to the server) – without having my feelings be hurt by the fact that I’m apparently clueless.

As I get older I’m finding it easier and easier to accept being wrong without there being any judgement on my value as a person or my skills or anything being involved. This is sort of the opposite of what I would have expected to have happened.

I love Penn & Teller..

Wednesday, April 3rd, 2013

http://www.youtube.com/watch?v=HpS1_Z0SJeA

I also enjoyed their stint on the West Wing, which I recently saw for the first time. 😉

Electrolux, the computer

Tuesday, March 26th, 2013

So, like many programmers of my generation, I grew up reading usenet posts like the Story of Mel. I had always assumed it was apocryphal, because the idea of a computer made by the Royal McBee typewriter company sounds unlikely.

Except that it’s all true. Here is the beast in question, complete with a lovely 50’s control panel that reminds me of a metal vacuum cleaner I had when I was young: LGP-30

In defense of high school students writing dark things

Thursday, January 3rd, 2013

Recently, Vinnie made me aware of a student who has been suspended for writing somewhat dark poetry (http://dailycaller.com/2012/12/31/san-francisco-high-school-senior-suspended-over-grim-poem-about-conn-shooting/.

I think that if we proceed down this path, we are doing our children a grave disservice.

My suspicions are that people who write about the dark things going on in their mind.. suicide, violence.. are the people who don’t act on those thoughts. Getting things out on paper actually helps some of us clear them from our minds, and also gives us the ability to see them in context. That’s not even going into the freedom of speech issues involved. I think it would be very unhealthy for us to insist that high school students not talk or write about the darker sides of the things they think, especially since they are immersed in a culture of violence. [It still angers me that you can show someone getting blown into tiny pieces in a PG-13 movie, but not people having sex – even though pretty much all healthy people have some sexuality in their lives and normally it is a happy thing that does not hurt people, whereas very few of us are gunning people down and whenever it does happen it’s certain to be a tragedy]

I don’t have anything but intuition to go on but I’m thinking that people who bottle up their dark thoughts instead of facing them (possibly by writing about them) are far more likely to go postal.