Showing posts with label computer science schmience. Show all posts
Showing posts with label computer science schmience. Show all posts

Tuesday, June 23, 2009

fluent helpers

Fluent C Sharp Language Extension Helpers - Part 1

So, I found myself doing a lot of for( int i = 0; i < n; i++ ){} stuff lately. So, I've decided to try something new. I've started a small collection of "Fluent Helpers" that alleviate a lot of the verbosity in C#.

About 28 characters (including spaces) for a simple for loop to do some constant iteration.

for( int i = 0; i < n, i++){

About 18 characters to do this (no pun intended):

Do.This( 5, () =>{

Here's an example:


Do.This( 5,() =>
{
Console.Write( "Hello " );
Console.WriteLine( "World!" );
}
);


Prints:

Hello World!
Hello World!
Hello World!
Hello World!
Hello World!

Now that feels much better on my hands, and looks much cleaner too, IMHO. Here's the simple implementation for Do.This:


public static class Do {

public static void This(int times, Action what)
{
for( int i = 0; i < times; i++ )
what();
}
}


I've already started a little library of these small syntax helpers I've collected. If you have any suggestions, please share! cool0003.gif

-Brian Chavez

Thursday, April 2, 2009

incomparably simple compare to example because I can never remember


using System;

class Program
{
static void Main()
{
string a = "a"; // 1
string b = "b"; // 2

int c = 0;

// When a is SMALLER than b
c = a.CompareTo(b);
Console.WriteLine(c);
// -1

// When b is BIGGER than a
c = b.CompareTo(a);
Console.WriteLine(c);
// 1
}
}

Friday, August 22, 2008

my anti-doppelganger

apparently someone has been getting a head start on my dream life: Technology Enhanced Learning

and not only does she have a career that is so similar to my own passions and pursuits, but we share the same name!

so on top of that, I am ALSO an artist, an author of a ton of books, a Real Estate CFO, an election campaign donor to John Kerry & Barack Obama, an animal specialist, a graduate of a Milwaukee high school, working at a communications firm in London, a cinematographer, a countess from Swinton, a member of the Society of American Silversmiths, and a child caretaker.

Tuesday, August 5, 2008

Its amazing what a little struggling does for the human spirit... well, I have to resign myself to relative struggling, as far as the upper-middle-class-privileged-white-female's human spirit goes.

Thursday, July 31, 2008

Unix 0, 1, and 2 Redirection

What does “> /dev/null 2>&1″ mean?

"There are three standard sources of input and output for a program. Standard input usually comes from the keyboard if it’s an interactive program, or from another program if it’s processing the other program’s output. The program usually prints to standard output, and sometimes prints to standard error. These three file descriptors (you can think of them as “data pipes”) are often called STDIN, STDOUT, and STDERR.

Sometimes they’re not named, they’re numbered! The built-in numberings for them are 0, 1, and 2, in that order. By default, if you don’t name or number one [of them] explicitly, you’re talking about STDOUT. (emphasis added)

Given that context, you can see the command above is redirecting standard output into /dev/null, which is a place you can dump anything you don’t want (often called the bit-bucket), then redirecting standard error into standard output (you have to put an & in front of the destination when you do this).

The short explanation, therefore, is “all output from this command should be shoved into a black hole.” That’s one good way to make a program be really quiet!"

Wednesday, July 16, 2008

Oracle Dates and Times

http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html

Wednesday, July 2, 2008

Nerdapalooza!

I thought of doing this a few days ago knowing it will totally help, in the same way that PConrad's CISC474 Wiki was an amazing way to house ass-sucking computer science-y quirkage, but from time to time (i.e. hopefully on a daily basis) I will probably post cryptic completely nondescript jargon and pictures to help me remember things I learn while I'm doing work ranging anywhere from the workings of computer languages, database management, development and debugging environments, and whatever else I feel like.

These posts are strictly my own musings and a personal attempt to increase my knowledge base. I'll be using "pseudocode" (actual code that I'll give preposterous pseudonyms, which is different from real pseudocode) in any examples or in any screenshots, and which will in no way be used for personal or commercial gain beyond that. Therein. Henceforth.

My first post will be about executing SQL commands from inside java. I also want to subsequent-post about C# function delegates, callback functions, oh and a bunch of weird stuff about Visual Studio, just off the top of my head, and indeed, the list will ever be increasing.