Thursday, November 8, 2012

Insert song title here.

I wonder if I may lie.
breathe slowly
open your eyes
can you hear me
and end this journey
what do you see?
were we ever really alive?
Lets switch off together
lets float to no more
goodbye...


goodbye to everything.

To slip the surly bonds of flesh and bone
expand through endless and infinite time
sallow pain and grounding,
bindings to nothing


This adorned box from Pandora,
Fastened around the neck of the willing and unwilling alike
Move, fall, slip away from this
push forever and make no difference


sleep, dream, fly, float, wake, die.
tears, blood, hate, rage, cry.
I turn an eye inward and expand forever more
I look outside and waste away


pathetic, useless, physical existence
when a journey awaits would the guards but leave.
Where does this lead? when does this leave?
Why must I breathe? Why must I grieve?

Does anyone really believe that this is how it should be?

Tuesday, November 6, 2012

SQL Server Templates

SQL Server Management Studio comes with a bunch of pre-built templates for scripting out procedures, functions, tables, administrative functions and more. All they are essentially are a .sql file with some special syntax in the script where values can be pasted into place. The special syntax is pretty easy to get a handle on, but at first glance can seem a little strange. Here's a sample of what you might see if you were looking at a SQL Server template (minus all the red lines I added).



There are several parts to this. Let's start with the window that's currently being displayed (in the picture, it's the window with the header "Specify Values for Template Parameters"). To get to this window, you must have a query window open in SSMS, and it wouldn't hurt to have a few tags in it (more on that later). In this query window, press ctrl+shift+M. I have no idea what the M is a mnemonic for... para(M)eters? Whatever. Once you're in this view, you'll be able to replace the special notation inside the script with values you input on this screen.

So how do you set that up? You put in tags with the notation
<[Parameter], [Type], [Value]>

[Parameter] is like the identifier for your replacements. Anywhere in your script, any time you have, say tagged in the script, all instances of that Database tag, will be replaced with the value you put in that popup window. This is the only part of the tag which is NOT optional. Think of it as your primary key.

[Type] is really just a hint to yourself about what datatype the script is expecting. Often times it's irellevant. If you're building a new Proc, you might have a tag which says , but you could just have easily put "Int" instead of "Sysname" and it wouldn't care. It's not a data type validator, it's just so that if you have a script which requires data of a certain type you know what to enter. It's worth noting that this is entirely optional. Also, if you change this data type throughout the script, it won't care. Only the first instance of the tag will be used to populate the [Type] column in the popup window.

[Value] is an optional default value in the field. In the example I showed above, more often than not, I'm looking for information_schema.columns, so I set the default of Parameter:SubType to "Columns". If i wanted to make it Routines or Tables, I just have to replace the "Columns" value with the value I want.



When you then click OK, all the values you have are propagated into those replaced tags throughout your script. It's worth mentioning that SQL treats each replacement of a value as a single undoable action, so if you've got a huge parameter list and you accidentally hit OK too soon, all the values you did (or probably didn't) submit will have to be undone one by one till you get back to your original script.



My final note on this is that if you don't have SQL 2012, or do and cant figure out how to use the snippets feature, get something like the SSMS Toolspack. It's free, and comes with a bunch of helpful tools, my favorite of which is a really simple code snippet interface. I've built little 2 - 3 character shortcuts for some of my most commonly used functions, such as the one I listed here. I type "info"+tab and it populate my query window with that code. I've got others as well, "tab"+tab for tables, "IX" for indexes and so on. When you combine this template format with the ability to call these templates up in a fraction of a second, you can really cut down extra typing time a LOT.

Monday, November 5, 2012

Evolutionary Causes of Depression

I read an interesting article hypothesizing an evolutionary cause for depression which stated that depression is a state people get in which is conducive to intent thinking and personal change. There's more to it than that and I suggest you read the article in full because it's quite good.

Having been depressed off and on for quite some time, i'd say that theory is imperfect, but as with all theories of psychology, they're applicable only to a generalized description of the disorder, so it still may hold water.

I was thinking about evolutionary causes for depression, and while I preface this with the giant asterisk of "since you can't really prove something like this, it could be just about anything", I still think it's interesting, if not morbid.

What if depression is a state of mind evolved to sort of say "shit or get off the pot"? Being depressed certainly brings about different patterns of behavior. Some are so painful and disparaging that the only way out is through a cathartic change of lifestyle. Some people simply fluctuate out of depressive states, some people change their lives to get out of depressive states, some people never leave their depressive states, and more often than not, those who cannot or do not ever leave their depressive states, take their own lives.

Could it be that depression is a means of either forcing people to improve their live or remove themselves from the gene pool? Again, this is a pretty morbid though, but while it's difficult to come up with true comparisons to a human psyche, there is plenty of self terminating behavior in computing. Competing threads may be automatically terminated if they are in a deadlock. anti-virus software isolates, quarantines, and destroys malignant software. It's not beyond the realm of possibility that humans have evolved their own sinister way of weeding out the unproductive.

Again, this is a generalized statement too, and i'll remind you, based on nothing but introspective experiences. There are a plethora of psychological ailments which probably have nothing to do with a normally functioning brain. True chemical imbalances like those brought on by under active endocrine systems, genetic defects such as trisomies, and brain damage from traumatic events are certainly not something evolution has chosen for. But within the realm of Major Depression discussed in this article, I think this is a interesting thought.

(Article):http://www.scientificamerican.com/article.cfm?id=depressions-evolutionary

Bing v Google

Microsoft is focusing a lot of effort on web and cloud based technologies, trying to diverge from their existing model of software installed on local PC's. This is a laudable goal, and is probably imperative given the way things are going. I'm actually a big fan of Microsoft's product, much to the affront of Open Source fanboys around the world, but that's just the way it is. I write in TSQL (SQL Server's dialect of SQL), I dabble in C#, I run Windows, and more.

Now unless you've been living under a rock or the oppressive heel of a World of Warcraft subscription, you've probably seen Microsoft's ads for IE9, Windows 8, and of course Bing.

Bing.

If you haven't yet, I'd go take the "bing it on challenge" to get more of an idea of what I'm talking about. Plus then I don't have to explain how it works. I'd also recommend reading Microsoft's explanation of the study.

The key findings of the study were the following:

"When the results were tallied, the outcome was clear – people chose Bing web search results over Google nearly 2:1 in the blind comparison tests. Specifically, of the nearly 1000 participants: 57.4% chose Bing more often, 30.2% chose Google more often; 12.4 % resulted in a draw.*

*The overall sampling error rate for the study is +/- 3 percent at the 95 percent confidence level."

As they say, the outcome is clear... ish. Ignoring the "draw" votes Bing won. There are certainly flaws in the study, but given that everyone on earth knows what google looks like, there are limitations to how the studies can be performed.

select 57.4 / 30.2 --1.9:1 select 54.4 / 33.2 --1.6:1 select 60.4 / 27.2 --2.2:1

But not to sound cynical, but who cares? There are more reasons people use Google than the sorting algorithm. Sure, if Google's algorithms were garbage, it might matter to the end user, but they're not. If we were to base our decision on which search engine was better based solely on this study, then Bing would be superior. But by how much? Google is great, Bing is greater. I also have a Gmail account. and a blogspot blog (a google product). I use youtube. I use google docs. I say "google it". I don't have nearly that much invested in Microsoft technologies when it comes to my web based suite of products. there's just not enough motivation to me to change from Google to Bing.

I think the main goal of this campaign by Microsoft was to try to remind people that Bing was there, and hope they can convert or incept enough users to make it a contender with Google. Will it work? In my opinion, no.

Wednesday, October 3, 2012

Relational Databases (or, How I'm Trying to Save Face)

Several months ago, I started getting active on SQLServerCentral and answered a post to a newbie about how to understand some common terminology about SQL; Rows, Columns, Fields, etc. Well, it turns out I didn't have a very good grasp on it, and the Godfather of SQL himself posted a thesis in response basically tearing me apart for not understanding the relational model correctly. (I wish I could find the article but I think at the time I was so mortified that I removed any trace of it from both my SQLServerCentral account and my email... shame on me).

That said, I think I've come up with a better way to describe a table in a relational database then analogizing it to an excel document - in laymens terms.. (Joe, if you're reading, please let me know!)

Think of a Table as an empty bank vault. At the entrance to the vault is a Guard wearing a shirt that says "Database Engine". Throughout the day, people come by to put things in the vault, remove things from the vault and change things in the vault. To do so, they have to bring in a box with a bunch of paper slips with things written on them; Words, numbers, hexadecimal expressions... and so on.

Now, when the vault was set up, the guard was given very specific instructions on what could be placed in the vault. Any box someone brought in may contain no more than some number of slips of paper. Each slip of paper must have a header on it saying what it represent (email address, phone number, etc). The guard is also responsible for making sure that certain slips of paper only have numbers of a certain length, or do not contain certain characters, and so forth. Each and every box MUST have a slip of paper with an email address. Then end result is, after the guard checks each new box, or instructions to change a box already in the vault, he gives it the OK, that it meets all the requirements set forth by the vaults creators. Over the course of the day, thousands, millions of boxes may come in and go out, but they all match the vaults requirements.

So what do you have? You have a room, with a bunch of containers with pieces of information that meet certain criteria. That's basically what a table is. The database engine constrains the types of data that enter a table so that at any time when you look in a box, you know certain pieces of information about that box. Note, this is a BIG departure from the way you would instinctively think about an Excel table, where it's basically a big (x,y) grid. Although there are parallels in how the data can be retrieve and thought about, the way the system stores the data and to understand how more complex queries work, it's critical to understand the difference.

I won't get into too much more, but you can start to see how things like joins, sorting, indexing and referential integrity flow from this. Along the indexing vein, say you want to know every box in a vault that has an email address that starts with the letter "T". Well, if all the boxes are just in a Heap on the floor (by the way, Heap is a SQL term for a table which has no "Clustered Index", or basically any logical physical ordering on the disk), you get to open each box, look at it's email slip, and then if its email starts with "T", add it to the list. How might one make this easier? Well if you physically structured the vault so that each box was placed adjacent to another box in alphabetical order, you could skim through the boxes till you found the section starting with "T", then see where the section starting with "U" started, and then just say "ok, everything between where "T" started and "U" started, has an email that starts with the letter 'T'". (again, the highly paid security guard is responsible for keeping them in order at all times.) Ok, so there's a bit more involved with indexing than just that, but when you think about a relational table like this, the operations you perform against them start to make a lot more sense.

Friday, September 14, 2012

(preface: drunk) Pretty sure life was made for dying. Thats kinda sad I guess, but we're all going there. When you leave this world, whether you're good or evil, the one thing you can count on is death. And taxes, but lets face it, we dont all pay those so even that's out. So lets talk about this thing. The big elephant in the room, the Grim Reaper, and the thing you're invetiably going to come face to face with in battle, and lose to. Whether you're a good person, a catholic, a christian, a jew or an atheist, you're going to die and I can almost guarantee you whatever you think happens when you die, is wrong. I mean the spiritually or scientifically.Personally I ascribe to the belief when you die, you just... stop.The program ends. The colorful catastrophe that is life just ceases. I've done drugs, I know how troubling an idea this is. Consciousness is a beautfil thing, and in the cosmic scheme of things, not to be overlooked, but it's just the program we live. It is spectacular because our survival is predicated on the belief that experiences should be spectcular. Milleneae of evolution has taught us to seek and enjoy the things which contribute to our own survival and more so, the propagation of our own species.The fact that we've invented the word "divine" doesn't make it any less of a mechanical process. So what's my point? Like any drug experience... supernatural and evanescent, it comes to an end. COming to terms with that is never easy, but once you accept it, there is a forced reassessment of reality. You end with a sour taste in your mouth or you grin and go to sleep. So why are we so opposed to the the ending of life any more than we would be a good night out, a movie, sex, or a few hits of ecstasy? Because we're irrational. Which, when you think about it, is a pretty absurd notion. We, being mechanical beings, programmed to perceive the world around us, yet evolutionarily built with blatent flaws. We strive for perfection. We may not realize it on the subatomic level upon which we operate, or understand it in the grand scheme of things, but we do. On average, the choices and decisions of any given person are a predictable occurance, and the death of one person is accounted for when things fall into place.This is not the same as fate or destiny, it's just that like any system, there is a middle of the bell curve which occurs despite the desires and actions of any one individual. Where am I going with this? Who knows. But however you die, it's probably not going to be remembered by most of humanity now, or ever to live from this day out. So live for yourself. or devote yourself to others. or waste away in a heroin induced fog. The universe will hardly blink at your passing. Do something that makes you feel good. If that's curing cancer, f yeah dude. if that's killing yourself, sorry things didnt work out your way. If that's murdering people... well we might hate you but whatever I get you. As un-illuminating as this may be when you think about it, please, just do what you want. As a great professor once told me, "life's too short to work for assholes". Do what you want. at all times. To all people. And once you start, don't give up, or people may get pissed.

Thursday, September 6, 2012

RIP Isis

Isis, you will be missed. I hope you're eating crickets up in huvven right now.

Monday, August 27, 2012

Oatmeal of the Gods

This stuff is so amazing I want to eat it all the time. .5 Cup dried oats 1 Cup water cubed pinapple cinnamon 2 packets splenda crushed walnuts 3 egg whites 1 egg 1) Make oatmeal according to recipe 2) Once it's done, put the egg whites and egg into a heated pan 3) Add oatmeal to the eggs and stir till the egg is cooked. 4) Remove egg and oatmeal mixture from pan and put it into a bowl. Add cinnamon, splenda, pinapple and walnuts (pretty much to taste). 5) ENJOY!

Monday, August 20, 2012

WARRIOR DASH 2012!

This morning I pushed through double quadricep strains and went up to the high country to compete in Warrior Dash. Got up there, and began pounding energy drinks. Finally after two bouts of pee breaks, we made our way to the starting line. A few switch backs and then about a quarter mile uphill and we got to the first obstacle.

1) Climb over 3 ft walls, under 2ft barbed wire, repeat x4

Whoo! The running is starting to catch up to me, but i push on through to obstacle... 2) balanced walk over a series of up down up down planks about 10 feet off the ground.

Crushed it, and look! I can see the next obstacle... wait, whats this quarter mile switchback I have to do? and why are my aforementioned quads stinging with every step? No time to bitch. Around the curve and up the next obstacle:

3) Climb up wooden rafters, then over the top, one rung down, you drop to the bottom.

more running.... 4) Run through tires

MORE RUNNING!

5) Jump over some fire.

Now comes the hellish ascent to the courses highest point. The grade gets gradually steeper and steeper and longer and longer, and to add insult to injury, there is another 6) up and over wooden steeple and 7) low pipes to crawl through. Made it to the top huffing and puffing, descend down a steep slope with ropes, and then get to obstacle...

9) Climb a rope over a wall, then drop down from the top of the other side to the ground.

Run some more (FINALLY DOWNHILL)

10) Cargo nets

run
11) swim through mud under barbed wire

Finish. Drink Beer. Wash. Rawr.

Monday, July 30, 2012

Reset SQL Server 2008 SSMS Shortcuts

Recently I've been playing with gVim trying to get into the lightning fast editing that is said to come with using vi as an editor. Problem is, unless I'm mistaken (I'd be happy to be proven wrong here) it's difficult or impossible to add the common tasks I use with SSMS. F5 to execute, remove results pane, new/next window etc.

An addon I was trying out called ViEmu added a lot of great vi functionality to SSMS. It's something that I think users adept at using vi would love. Maybe even an SSMS user could learn to love. But I'm new, and like anyone starting out using vi, it's frustrating, so in lieu of the hundreds of projects looming which need to get done, I guess learning vi will have to wait.

What does this have to do with my posting? This addon (as do many other SSMS addons) remaps many commonly used shortcut. Ctrl-r to hide results pane, alt-w to access window switching, even ctrl-n for new query window. Begin google search for resetting keyboard shortcuts in SSMS.

Turns out for whatever reason, SSMS really doesn't like you being able to easily change your shortcut settings, and a surprising dearth of information was available on the interwebs on this topic. I got it to work, so let me distill what I can for you.

  1. SSMS doesn't store keyboard shortcut information in the registry but rather in local files so uninstallation won't necessarily help.
  2. the files are user specific so they are stored in AppData as opposed to somewhere in the install directory.
  3. SSMS stores keyboard shortcut data in .vsk files (two of which seem to be responsible for the settings concerning SSMS


You have to go to your app data directory. Depending on your version and how your machine(s) is/are setup, your path may look something like this:

C:\Documents and Settings\ShayShay\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell

in there, you're looking for two .vsk files - User.vsk and/or Current.vsk. I found them both in the directory mentioned above, but it sounds as though they may be in slightly different paths in the SSMS app data dir.

Point is, close SSMM, delete those two files (or as i did, cut and paste them to my desktop to be safe) then start up SSMS. Try something simple like select 1 + f5 = ctrl-r (toggle results pane) or really whichever your previously existing shortcut was. If it's still borked, time to go hunting through your app data dirs for other offending .vsk

NOTE: I'm not sure what the result of deleting .vsk files at will are. So far, SSMS looks like it auto-remakes the necessary files wiht default settings (what I wanted) but always be careful snipping out random files. I'd really recommend cutting and pasting them to desktop or something so that if things go horribly wrong, you dont end up in a worse situation than you started in.

Monday, July 23, 2012

Despite the fact that reality is really just a construct of the mind – filtered sensory input through a veil of individual experience, at least on a personal scale – most sane people have a good grip on what’s real to them. It’s really cool to think about what reality means to each of us. The same painting, song, phrase can have a profoundly different impact from person to person. When you think about the fact that we can play out what-if scenarios, imagine being in outer space, fantasize about island vacations or what might happen if we run this red light, reality is really just a single path, a single slit through which we choose to observe our reality flow through. In reality, the membrane separating what could be, what is, and what is not is razor thin. It may not, and in all likelihood, doesn’t exist, at least not in the sense that a traditional boundary might exist, but whatever interplay of neurons allows for the distinction, let us refer to it as a membrane. Somewhere however, we draw the line between fact and fiction and navigate the universe in a way which is coherent and stable. What happens when that membrane fails? When the stories created by sensory inputs are given equal credence to the next? When the conscious mind is unable to distinguish between the “right” and “wrong” paths? Right, in this sense means the version of reality which most closely lays on top of the functionality of the objective world. Certainly, there is no true “right” path, but as goes one of my favorite quotes, “it’s a little wrong to say a Tomato is a vegetable. It’s very wrong to say it's a suspension bridge”.

Somehow out of the massive amount of information which flows through our senses in a given period of time, we have to come up with a coherent view of reality. Additionally, we string individual moments together to tell an ongoing story, one which is guided by the preceding moments as well as the current. Take for example the idea of the butterfly effect. Assuming the collapse of the membrane between fact and fiction is instantaneous, the individual would instantly have to choose between what seem to be a very large set of congruent versions of reality. Once chosen, from moment to moment new realities will have to be chosen. In my entirely subjective opinion, if a coherent thread cannot be found, consciousness ceases to occur. Sensory inputs “short out” or fizzle to nothing as does the majority of the input which we don’t actively process. However within the noise, if the mind can catch on to a theme connecting realities, that story will begin to play out, however convoluted it’s path until the membrane can be reestablished and align thought with the past of most congruence.

If you’ve ever listened to someone paranoid about, say Big Brother spying on them, or perhaps listened to yourself as you hear the floorboards creak, the stories, objectively are pretty ridiculous. A car has been parked outside for a week. At the same time, your neighbor hasn’t been seen at home in roughly the same time. And who was on the other end of that hang-up call this morning? The stories contain a thread of continuity at least, and sometimes while floating through the realm of possible interpretations of reality, a thread of continuity is the only reference point we have to an underlying reality.

Like trying to follow a straight line on the ground in a strobe light, for the most part it’s doable. The faster the strobe or the longer the periods of illumination, the easier it is to trace the line of reality. Even in slower strobes, you can correct your course quickly enough so that the path is always within grasp. The longer the darkness however, the easier it is to stray away from the line without even knowing it. After a time your brain thinks you’re moving straight when in fact you’re far from the center. What happens if the light never turns back on? How do you know whether you’re actually on the line or whether your brain just wants to believe that it is?

Monday, June 18, 2012

Wednesday, May 30, 2012

SQL XML SPID Settings

I found some nifty uses of xQuery and xPath expressions in SQL recently, but I also ran into some errors promoting to a server with some SPID settings. Turns out there's a page on MSDN with the exact settings that need to be set in order for things like xml.query() and xml.nodes() to work.

ANSI_NULLS ON
ANSI_PADDING ON
ANSI_WARNINGS ON
ARITHABORT ON
CONCAT_NULL_YIELDS_NULL ON
NUMERIC_ROUNDABORT OFF
QUOTED_IDENTIFIER ON

http://msdn.microsoft.com/en-us/library/ms188285%28SQL.105%29.aspx