.net reflection of privates

On IRC, there was someone who had come to the (incorrect) conclusion that unlike Java, good ol .NET reflection could only see public members.  Nevermind that reflection would arguably be useless in such situations (outside of dynamic language-type needs), but the (simple) answer is to use the BindingFlags parameter to specify Instance (default is static) and NonPublic (default is public) when looking for targets with those properties.

23:40 [ Zero] I think I’ve found the problem.  Reflection can only see public members.

Not sure how this will copy-paste, but hopefully you’ll get the point:

using System;
using System.Reflection;

namespace Sample
    class Program
        static void Main(string[] args)
            Type targetType = typeof(HasPrivateMethodFoo);
            ConstructorInfo ctor = targetType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null);
            MethodInfo method = targetType.GetMethod(“Foo”, BindingFlags.Instance | BindingFlags.NonPublic);
            object instance = ctor.Invoke(new object[0]);
            method.Invoke(instance, new object[] { “string to print” });

    class HasPrivateMethodFoo
        private HasPrivateMethodFoo()
            // do nothing
        private void Foo(string bar)


Friends don't let friends PowerPoint

Now, I’ll be the first to admit that I’ve actually seen a few great presentations where PowerPoint actually was incredibly useful, and made for a better experience.  But too many times I’ve seen it come across like 1990’s html – IOW, the author was far more/too focused on the tool and using it rather than the end goal of what they’re trying to get across.  

I think it’s somewhat natural to tools you don’t feel innately familiar with, so you end up spending so many mental cycles in the toolset that you’re wasting the valuable ones you should be spending on the actual material.

With that in mind, I find this advice incredibly refreshing, both because I also love OneNote as he does, but also because I think he’s really on to something here.  Not only is OneNote more flexible (at least in my experience), but as a tool it does an incredibly good job of “getting out of your way” – it distracts you as a tool as little as possible, letting you focus on the actual goal (the material, the topic, the concepts you want to get across). 

Only after you have all that great material together do you then switch back to PowerPoint, where PP will still get in your way and force you to spend too much time thinking about the tool you’re using, but it’ll do so only *after* you have your material together and your thoughts at least somewhat solidified.

Office Rocker! : Death by PowerPoint – Giving better presentations

Write your pitch in OneNote not Powerpoint

Readers of OfficeRocker will know my love of OneNote but try this – don’t write your presentation in PowerPoint. If you do it will be too slideware and stilted. Instead try OneNote. Using OneNote, create a scrapbook of your thoughts, move text about and group ideas, scribble thoughts, pictures – even ideas for jokes. Your pitch will be more creative and the flow improves. I then think about what slides to create that will support and reinforce my message. Do it this way, not the other way round and you will be a more powerful presenter.

Technorati Tags: , ,

keep it simple, and measure before you tune

Over-engineering (still) sucks. KISS! Sometimes it’s not just that the abstraction was leaky – it’s that the abstraction was not needed.

Unix philosophy

# Rule 1: You cannot tell where a program is going to spend its time. Bottlenecks occur in surprising places, so do not try to second guess and put in a speed hack until you’ve proven that’s where the bottleneck is.

# Rule 2: Measure. Do not tune for speed until you have measured, and even then don’t unless one part of the code overwhelms the rest.

# Rule 3: Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don’t get fancy. (Even if n does get big, use Rule 2 first.)

# Rule 4: Fancy algorithms are buggier than simple ones, and they are much harder to implement. Use simple algorithms as well as simple data structures.

# Rule 5: Data dominates. If you have chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.

# Rule 6: There is no spoonRule 6.

del.icio.us bookmarks for the week ending July 22, 2006

Bookmarks added by del.icio.us user jmanning between July 16, 2006 and July 22, 2006

In the garden of Boeing…

Make sure to read both the post (hilarious) and at least the best of the comments (you’ll figure it out)

Snakes on a Motherfucking Plane

Next thing you know the copycats will create gems like:







memories of machines gone by

% man -k continue
apropos: Database /var/cache/man/index.db corrupted; rebuild with mandb –create
% sudo mandb –create
12 man subdirectories contained newer manual pages.
4219 manual pages were added.
0 stray cats were added.

My first linux (pre-1.0 kernels! fun!) box (and incidentally, my first EFNet irc server) was the 2MB-RAM-but-still-running-X 386sx/33 (that’s right, no fpu!) stray.catt.ncsu.edu

when apache can't kill a child process during shutdown

i still had a debugger attached, so even 9 didn’t do the trick 🙂

[Fri Jul 21 23:37:04 2006] [warn] child process 31751 still did not exit, sending a SIGTERM
[Fri Jul 21 23:37:04 2006] [warn] child process 31751 still did not exit, sending a SIGTERM
[Fri Jul 21 23:37:05 2006] [warn] child process 31751 still did not exit, sending a SIGTERM
[Fri Jul 21 23:37:10 2006] [error] child process 31751 still did not exit, sending a SIGKILL
[Fri Jul 21 23:37:26 2006] [error] could not make child process 31751 exit, attempting to continue anyway
[Fri Jul 21 23:37:26 2006] [notice] caught SIGTERM, shutting down

Unfortunately, the debugger wasn’t responding any more, and while I could kill the debugger, it’s left the process (which still has my port 80 bound) stuck in a syscall (and can’t connect to it from a new gdb), so I may be out of luck in getting real http traffic served again (at least on 80) without a reboot since the process is stuck sTopped.

% ps auxwww|grep apac
www-data 31751  0.0  3.4  15452  8748 ?        T    21:51   0:00 /usr/sbin/apache2 -k start -DSSL
% sudo netstat -pnl|grep :80
tcp6       0      0 :::80                   :::*                    LISTEN     31751/apache2

[Later] Ok, actually, it turns out this particular process was stuck in a syscall (for some reason i though being in a syscall would be a different process state) waiting on traffic from a stuck client – once i killed the socket on the client machine (taking down its network interface), the apache2 process returned back to user space and died fine.  So, I didn’t have to reboot.

This makes me wonder where Linux is these days with interruptible syscalls (I could assume based on this data point, but that may be unfair), though.

how to fetch the source from a GotDotNet project

Was helping out on IRC and helped a user with the GDN interface enough for them to download the source of a project.

Workspaces: Start using GotDotNet Workspaces Source Control

23:08 [ Mental_Floss] Hello. Has anyone attempted to use the gotdotnet.com workspaces feature?
23:08 [ Flav] i’ve got a couple workspaces on GDN – why?
23:09 [ Mental_Floss] Well, a friend recently added me to a workspace, and I’d like to download the entire source control directory. How can I do that?
23:09 [ Flav] Mental_Floss: sure – they have a few options available, a winforms interface (packaged as an activex control IIRC), a Visual Studio source control interface, and something else i forget
23:10 [ Mental_Floss] Yeah. I’m pretty sure I’m using the winform one, but I set that one a while back, and have no idea how to change it back.
23:10 [ Mental_Floss] to be honest, that sites frustrating as hell.
23:11 [ Flav] Mental_Floss: agreed, it’s a really bad interface unfortunately
23:12 [ Mental_Floss] So, if yu could explain those two things (getting the whole source control dir is more important) i’d really appreciate it
23:13  * Flav logs in to GDN to try and remember how to switch source control interface choice
23:14 [ Mental_Floss] cool. i’ll go smoke a cigarette. that site has gotten me all tense and angry
23:19 [ Flav] Mental_Floss: when you’re logged in and viewing the workspace, select “Source Control” from the left nav bar, then when the next page comes up (and may start the winforms app) the top of the nav bar should have a “Source Control” section that includs “Interface selection”
23:23 [ Mental_Floss] AHhh yes. man that left nav bar is weak too. I was using the html version. If i switch to winform im sure i can dl the whole thing
23:23 [ Flav] Mental_Floss: however, i just used the winforms interface (the one for .net 2.0) and after picking a local folder for the workspace, it was easy to select and right-click the root node in the winforms left panel and “get latest” which downloaded all the source
23:23 [ Mental_Floss] thanks a ton flav
23:23 [ Flav] Mental_Floss: the other interfaces should work as well, i just used the .net 2.0 one because that’s what i currently have selected
23:24 [ Flav] Mental_Floss: on a related note, a lot of the sins of gotdotnet will hopefully be solved as codeplex.com comes along
23:25 [ Mental_Floss] codeplex huh? is it up yet?
23:25 [ Mental_Floss] hmm ok that looks nicer by miles

Technorati Tags: