Tuesday, December 28, 2010

Bad Ingredients to watch out for!!

FD & C Yellow #5 (aka Tartrazine)
Red 40

Monday, December 20, 2010

Trading Apple volatility

Apple: Using Technical Analysis to Trade Volatility


By Mark Sebastian - 12/16/10 - 2:53 PM EST

Tickers in this article: VZ GOOG VOD AAPL

There are thousands of traders that use options to take advantage of technical analysis in a particular stock. When a stock bounces off a support point, traders will buy calls or sell puts and vice versa for a resistance point. In my time mentoring traders at OptionPit.com I am shocked how few traders use that same technical analysis skill for option implied volatility. In fact, because volatilities tendency to revert to the mean, it almost makes more sense to use technical analysis in volatility than it does stock price. This brings me to Apple(:AAPL).



AAPL 30-day implied volatility (IV) is sitting not on 52-week lows, but five-year lows. Basically, one can buy an AAPL at-the-money straddle at the cheapest price, relative to the price of the underlying since before AAPL was trading in the triple digits. Before getting too excited about how cheap this implied volatility is, do not forget that implied volatility can be cheap for a reason. If we take a look at the realized volatility (sometimes called historical volatility) of AAPL since its last earnings announcement, one would not be impressed by its movement. Even using the more stringent high-low realized volatility (calculating the range based on the absolute high and low trade prices) AAPL volatility has been around 20%. Using traditional calculations, AAPL implied volatility is in the single digits. It is actually at a two-year low. Even with the holidays coming up, these levels are too light. As someone who follows implied volatility and realized volatility very closely, I have a hard time imagining that AAPL will continue not to move for the next 30 days. The market will want to know how many iPhones were sold over Christmas, when exactly AAPL begin selling phones for Verizon Wireless(:VZ/VOD), how Google's(:GOOG) Android doing relative to AAPL. Basically, there are a lot of questions that could send the stock in either direction.









Apple (AAPL) Volatility Two Year

Source: Livevol




The red represents 30-day implied volatility.


The gray represents 30-day realized volatility.



How does one play AAPL with implied and realized volatility this low? For starters, I would write a piece challenging Brock Lesner to a fist fight before I would write a piece suggesting traders sell any kind of option in this product. The front month is at record low volatility, February and March, which are likely to have some earnings, are not quite there, but are also inexpensive historically. For those with a directional bias, while the at-the-money implied volatility is low across the board, vertical skew in AAPL is still a little steep (most likely trying to make up for the low volatility on the 320 strike), I would consider looking at vertical spreads in which I bought the at-the-money and sold the out-of-the-money. For those that do not have a directional bias, the fund I am working with, just dipped our toe in the AAPL January 320 straddle, buying it for $19.85 (AAPL was around $321.00 at the time). With the stock $1.00 higher at ~1:15 p.m. EST, the price is more like $19.00. If this straddle falls further, I probably buy more at varying price levels.



Remember, with a straddle it is not just the price movement that matters, it is the implied volatility. For this trade to work, I need AAPL to move in one direction, preferably fast. Hopefully, this will cause an increase in demand for insurance, running up the value of my straddle. My maximum loss on this trade is going to be $16.00, or 15%. I am hoping to sell this sucker for at least $25.00, a gain of over 25%. This trade has a decent amount of decay risk and should not be entered by someone who is not aware of the risks of time decay.



Trade: With AAPL trading at $322.25, buy to open AAPL January 320 calls for $11.25 and buy to open AAPL January 320 puts for $8.70.



At the time of publication, Mark Sebastian held a position in AAPL straddles.



Mark Sebastian is COO and Director of Education for Option Pit Option Mentoring. Sebastian is a former market maker on both the Chicago Board Options Exchange and the American Stock Exchange. Along with his role directing the path of education for Option Pit, Mark is currently the director of risk for a private hedge fund. He started the popular blog Option911, which is now the Option Pit blog. Sebastian has been published nationally on Yahoo! Finance, is a featured contributor for TheStreet's OptionsProfits, SFO, OptionsZone and is the managing editor for Expiring Monthly: The Option Traders Journal. Mark has a Bachelor's in Science from Villanova University.



OptionsProfits For actionable options trade ideas from a team of experts, visit TheStreet's OptionsProfits now.

Wednesday, December 1, 2010

weekly options and other TOS stuff

WEEKLY OPTIONS

makes it affordable for expensive underlyer (which also has expensive monthly options)

be sellers - take advantage of faster time decay

learn more on this...



OTHER STUFF

use sizzle index on your positions with MarketWatch. If the index is 1 to 2 or 3, it's a quick way to know nothing major has happened in your instruments. If you see, over 30 or 50, something is happening, take a look and maybe do something.

when trading spreads, the price defaulted by TOS is actually MID PRICE (which is good, protects you). If you go to NAT (natural), you are alomost always overpaying.

VIX futures are coming soon

Usually, close positions a few days (4 or 5) before expiration cuz after that, risk increases sig

when shorting singles or spreads, how to understand "assignment" scenarios?

my question of "how to chart/see history of IV relevant to your trade (single or spread) as opposed to composite IV" was not answered yet. They proly didnt see it

Monday, October 18, 2010

options: intraday pricing with greeks

I'm excluding Theta effect in intra-day option pricing here (although time value erosion should be continuous in theory)

Time1
         Delta        Vega         
         0.5            0.2
         PU           IV              Option Mkt P         
         163.34     47.86         8.625

Time2
         162.5      47.05         8.05
         ============
         -0.42      -0.162        8.043

Note 8.043 is very close to 8.05. Experience shows this to be true in general for small underlyer price changes.

Saturday, October 16, 2010

recipe: papaya salad

so awesome

need a deep mortar and pestle

garlic
green or red chilli
green beans
peanuts
shredded papaya (you can shred papaya with a simple house knife as shown in this video)
dried shrimp
palm sugar (it's liquidy)
tomatoes
lime juice
fish sauce

suggestions

you can add shredded carrots too

garnish with toasted peanuts or cashews

recipe: fish cake

I like the vietnamese style.

Ingredients: (4 người)

- 300g fish fillet

- 150-200g ground pork

- 3 stalks spring onion, finely chopped

- 1 small bunch of dill, finely chopped

- 1.5 tbs fish sauce

- 1/2 tsp ground pepper

- vegetable oil, to pan fry

Cooking:

- Combine all the ingredients, except for the oil – of course. Use the back of a spoon to mix and press the mixture hardly until you get a nearly fine paste.

- Shape into small flat balls of free size.

- Heat the oil in a large frying pan, fry the fish cakes until golden brown on both sides.

recipe: salad: Vietnamese Crab Salad with Rice Noodles

Ingredients

50g (2oz) sugar, or more to taste
50ml (2oz) fish sauce
50ml (2fl oz) lemon or lime juice
1-2 small chillies, seeded and sliced finely
2 cloves of crushed or finely grated garlic
2 tsp finely grated ginger
125g (4oz) thin or medium rice noodles, softened by sitting in a bowl of boiling water for 5 minutes, drained and rinsed
300g (10oz) cooked crab meat (brown and white meat if possible)
300g (10oz) cucumber, deseeded and chopped
150g (5oz) radishes, trimmed and sliced
75g (3oz) peanuts, toasted under a hot grill until golden , then skins rubbed off (and blown away outside), and chopped roughly
2 tbsp chopped coriander

Method

Mix all the ingredients for the dressing. In a bowl, toss together the dressing with the drained noodles, then add the brown crab meat (if using), the cucumber and the radishes and toss.
Place on a serving plate or shallow bowl.
Sprinkle over the white crab meat, the toasted peanuts and the chopped coriander and serve.

recipe: fish: White fatty fish with madras curry powder

You may have a hard time wrapping your brain around pairing madras curry and olives, but if you think about it a moment, it really works. The French regularly use many of the ingredients that are in curry with olives—you’ve probably tasted the combination and not even known it. But you’ll see for yourself how well these potent ingredients harmonize in my Seared curried butterfish with warm olive chutney.

Serves 4

Ingredients
2 tablespoons madras curry powder
1/4 cup rice flour
4 pieces butterfish or other fatty white fish
3 shallots minced
1/2 cup mixed olives, pitted, minced
1 large tomato, 1/4-inch dice
Juice of 1 orange
2 tablespoons chopped cilantro
Sea salt and freshly ground pepper
Canola oil for cooking

Directions
On a pie plate, combine the curry and rice flour. Season fish with salt and pepper. Dredge the fish fillets on both sides into the rice flour mixture. In a cast-iron pan over medium-high heat coated lightly with oil, sear the fish until golden, brown and delicious, about 8 minutes total. Remove fish and wipe out pan. In same pan coated lightly with oil, saute the shallots, then add olives, tomato and orange juice and heat through. Toss with cilantro and serve 1 heaping tablespoon over each fillet. Serve on banana leaf.

Friday, October 15, 2010

options: time value over wknd counts or not?

10/15/2010 Fri GOOG soared after earnings last evening
This news bodes well for AMZN whose earnings comes out Tuesday or so I believe. I wanted to buy call today (with the intention of closing out before Tuesday since volatility crunch could again decrease the option value) but I didn't like theta eroding option value over the wknd.

In theory, wknd should not matter i.e. there should be a usual one day of time value erosion. However, I feel there is some level of additional value erosion going from fri to mon.

Does that happen? Let's see!

How do we do this? On Monday morning, at the open, record the option prices and see if they reflect any ADDITIONAL time value erosion from the wknd or not!

Note: If there is a significant level of price change, then answer should be YES. If there is a small change only, the answer is IDK.

AMZN
fri 11:47AM P=161.27
B A DGVT IV VOL OI
nov 165c
7.40 7.55 .46 .02 -.13 .20 45.09 314 2789
nov 165p
11.20 11.30 -.53 .02 -.13 .20 45.52 78 971

fri close P=164.64
nov 165c
9.40 9.55 .53 .02 -.13 .21 46.13 1730 2789
nov 165p
9.75 9.85 -.47 .02 -.13 .21 47.25 713 971

=============================================

mon at or around open P=??
nov 165c
???
nov 165p
???
=============================================

calculations

Tuesday, August 3, 2010

11 supplements to consider












http://www.consumerreports.org/health/natural-health/dietary-supplements/safe-supplements/index.htm?EXTKEY=AYAHLTH02



 



11 supplements to consider




Last reviewed: September 2010


xmlns:st1="urn:www.microsoft.com/smarttags"
xmlns:w="urn:www.microsoft.com/word">
These popular supplements, listed in alphabetical order, have been shown to
likely be safe for most people and possibly or likely to be effective in
appropriate doses for certain conditions. Talk to your doctor or pharmacist
before starting any supplement. Most supplements haven't been studied in
pregnant or nursing women. The list of interactions and side effects is not
all-inclusive.


xmlns:st1="urn:www.microsoft.com/smarttags"
xmlns:w="urn:www.microsoft.com/word">
















































































NAME

(also known as)

EFFICACY FOR SELECTED USES

SELECTED POTENTIAL SIDE EFFECTS

SELECTED DRUG INTERACTIONS

style="FONT-WEIGHT: bold" title="CALCIUM">CALCIUM

(calcium carbonate, calcium citrate, calcium gluconate)

Likely effective in combination with vitamin D in preventing and treating bone
loss and osteoporosis. Taken daily, appears to reduce some PMS symptoms.

Belching, gas.

Calcium can decrease the effectiveness of certain antibiotics, osteoporosis
drugs, and thyroid drugs.

style="FONT-WEIGHT: bold" title="CRANBERRY">CRANBERRY

(American cranberry, large cranberry, cranberry extract)

Possibly effective for preventing recurrent urinary-tract infections.

Large amounts can cause stomach upset, diarrhea.

Might increase the effects of the blood thinner warfarin.

style="FONT-WEIGHT: bold" title="FISH OIL">FISH OIL

(EPA/DHA, omega-3 fatty acids, PUFA)

Effective for reducing triglyceride levels. Likely effective for decreasing the
risk of heart attack, stroke, and progression of hardening of the arteries in
people with existing heart disease.

Fishy aftertaste, upset stomach, nausea, loose stools. High doses can increase
levels of LDL (bad) cholesterol in some people or increase the chance of
bleeding.

Might increase the effect of blood-thinning drugs and high blood pressure
medications.

style="FONT-WEIGHT: bold" title="GLUCOSAMINE SULFATE">GLUCOSAMINE SULFATE

(G6S, glucosamine sulfate 2KCl, glucosamine sulfate-potassium chloride)

Likely effective treatment for reducing symptoms of osteoarthritis of the knee.
Might also help slow progression of osteoarthritis.

Nausea, heartburn, diarrhea, constipation, headache.

Might increase the blood-thinning effect of warfarin and cause bruising and
bleeding.

style="FONT-WEIGHT: bold" title="LACTASE">LACTASE

(beta-galactosidase)

Likely effective for reducing gastrointestinal symptoms in lactoseintolerant
people when used before consuming lactose or when added to milk.

No reported side effects.

None known.

style="FONT-WEIGHT: bold" title="LACTOBACILLUS">LACTOBACILLUS

(acidophilus, acidophilus lactobacillus, probiotics)

Possibly effective for preventing diarrhea while taking antibiotics.

Gas. People with poor immune function should check with their doctor first.

Might cause infection in people taking immunosuppressant drugs.

style="FONT-WEIGHT: bold" title="PSYLLIUM">PSYLLIUM

(blond plantago, blonde psyllium, plantago, isabgola)

Effective as a bulk laxative for reducing constipation or softening stools.
Likely effective for lowering cholesterol in people with mild to moderately high
cholesterol.

Gas, stomach pain, diarrhea, constipation, nausea. Some people can have a
serious allergic response that requires immediate medical attention.

Might decrease the effectiveness of carbamazepine, an antiseizure drug; digoxin,
a heart drug; and lithium, for bipolar disorder. Might cause low blood sugar
when taken with some diabetes drugs.

style="FONT-WEIGHT: bold" title="PYGEUM">PYGEUM

(African plum tree, African prune, Prunus africana)

Likely effective for reducing symptoms of an enlarged prostate.

Nausea, abdominal pain.

None known.

style="FONT-WEIGHT: bold" title="SAMe">SAMe

(ademetionine, adenosylmethionine, S-Adenosyl-L-Methionine, sammy)

Likely effective in reducing symptoms of major depression, reducing pain, and
improving functioning in people with osteoarthritis.

GI symptoms, dry mouth, headache, mild insomnia, anorexia, sweating, dizziness,
and nervousness, especially at higher doses. It can make some people with
depression feel anxious.

Might lead to a toxic reaction when taken with the cough suppressant
dextromethorphan, certain antidepressants, or narcotic pain relievers. Might
worsen symptoms when taken with the Parkinson's drug levodopa.

style="FONT-WEIGHT: bold" title="ST. JOHN'S WORT">ST. JOHN'S WORT

(Hypericum perforatum, Saynt Johannes Wort, SJW)

Likely effective for improving symptoms of some forms of depression.

Insomnia, vivid dreams, anxiety, dizziness, headache, skin rash, and tingling.
It can cause skin to become extra-sensitive to the sun.

Can decrease the effectiveness of a wide range of drugs, including birth-control
pills, heart medications, HIV/AIDS drugs, and warfarin. Might also increase the
effects or side effects of certain antidepressants.

style="FONT-WEIGHT: bold" title="VITAMIN D">VITAMIN D

(Cholecalciferol, vitamin D3, ergocalciferol, vitamin D2)

Likely effective when taken with calcium to help prevent osteoporosis. Might
help reduce falls in people with vitamin D deficiency and bone loss in people
taking corticosteroids.

Extremely large amounts might cause weakness, fatigue, headache, and nausea,
though side effects are rare.

Might reduce the effectiveness of some medications, such as atorvastatin
(Lipitor), other heart medications, birth-control pills, HIV/AIDS drugs.

 

 


xmlns:st1="urn:www.microsoft.com/smarttags"
xmlns:w="urn:www.microsoft.com/word">Source: Natural Medicines Comprehensive
Database, Professional Version, June 2010




Thursday, May 13, 2010

My Continualy Changing Options Strategies

Given that I decide to take on a trade based on volatility risk, consider the following:
(1) Read news. If anything significant jumps out (like earnings anouncement, new guidance, possible takeover, new contracts etc. or even something related to market at large, like interest rate change, political crisis, unemployment rate etc.) and I am reasonably swayed to one side of price movement, factor that in to my trade. This is ok, you have got to take a view sometimes. Just make sure that this view does not represent 100% of your trading risk. On the other hand, if you cannot reasonably be swayed to one side of price movement (whether there is significant news on the underlyer or there is absolutely none), then stick to 100% of volatility risk.
(2) Make the trade. Always embed a stop loss. I like the trailing stop or trailing stop limit (the latter is little riskier)
(3) Constantly modify your trade, relative to market news and changing volatility? how to do this?

Options Trading has essentially 2 strategies

Abbreviations used
==============
ST = Short Term
LT = Long Term


With options trading, you are essentially trading

(1) direction in which the underlyer will move ST

and/or

(2) volatility of underlyer

Strategy (1) is very difficult to achieve as a LT goal, akin to the difficulty of beating the casino over a long period of time. Even though you might still believe you have a good chance of consistently making profitable trades based on (1), if you haven't started trading strategies based on (2), you are missing out big time and honestly you are bound to be doomed over LT!! (2) is far more achievable LT than (1). Period.

It's true what I said above is nothing new - it's been explained, researched and demonstrated to be true in academia and on the street for ages. Still, what makes people forget and concentrate on (1), at least initially? The answer is simple. (1) is easier to understand and make decisions on. Initial success might even push you into playing more. If you are a bit shrewd, you probably understand the winning streak won't last very long. Yet you push it to one more play, thinking the luck has probably not changed course yet and sure you can afford to lose this one play and still profit if you stop right afterwards. Ha! Know this feeling? And then you keep going even after that one loss, thinking oh well, what are the chances of another loss again when I have made more wins so far? I swear if I win 2 more, I will stop and go home happy. On and on! I mean come on!! I happen to be a pretty good player at roulette and I have had far more wins than losses so far in my life but I also know when to stop, either after losing the entire budget I had set aside BEFORE entering the casino (NOT after) or after I have made some profits that I'm comfortable with (not letting my greed get in the way).

As of writing this blog, I'm beginning to focus more and more on (2) while still trading (1), albeit applying more restraints on (1) than I had before. Like many traders, I find it impossible to let go of (1) entirely. I will need to act on it more judiciously but definitely play it.

Conclusion:
==========
Trade (2) consistently while trading (1) judiciously, knowing that (1) alone will likely make you a loser over LT.

Friday, April 16, 2010

spring pasta shrimp and asparagus

heat some olive oil
add white wine (may flame)
a slice of lemon
add chicken broth
add chive

add uncooked shrimp and cut up asparagus
add small amt of grated cheese

dump cooked pasta into the pan

serve after adding some parsley

Sunday, March 28, 2010

health checkup

% of body fat
breakdown of ldls and hdls
state of kidney and liver health
ask if taking whey protein is ok, 105g daily, if im working out.

Wednesday, January 27, 2010

Writing a VBScript

'-------------------------
'Functions
'-------------------------
Function WriteRecordSet(aRecordSet,aFile)
Dim lRecordsetString
Dim lngFieldsIndex
Dim lngIndex
Dim lFieldValue
lRecordsetString = ""
lngFieldsIndex= aRecordSet.RecordCount - 1
For lngIndex = 0 to lngFieldsIndex
if lngIndex = 0 then
lRecordsetString = Cstr(aRecordSet.Fields(lngIndex).Name)
else
lRecordsetString = lRecordsetString & "" & Cstr(aRecordSet.Fields(lngIndex).Name)
end if
Next
aFile.WriteLine(lRecordsetString)
lRecordsetString = ""
aRecordSet.MoveFirst
Do While (Not aRecordSet.EOF)
For lngIndex = 0 to lngFieldsIndex
if (aRecordSet(lngIndex).Value = null) Then
lFieldValue = "DBNull"
else
lFieldValue = Cstr(aRecordSet(lngIndex).Value)
end if
if lngIndex = 0 then
lRecordsetString = lFieldValue
else
lRecordsetString = lRecordsetString & "" & lFieldValue
end if
Next
aFile.WriteLine(lRecordsetString)
aRecordSet.MoveNext
Loop
aRecordSet.MoveFirst
End Function

Function WriteArrayOfArray(aArrayOfArray,aFile)
Dim strArray
Dim lngUBound1
Dim lngUBound2
Dim lngIndex1
Dim lngIndex2
lngUBound1 = UBound(aArrayOfArray, 1)
lngUBound2 = UBound(aArrayOfArray, 2)
For lngIndex1 = 0 To lngUBound1
For lngIndex2 = 0 To lngUBound2
strArray = strArray + "[" & lngIndex1 & "," & lngIndex2 & "] = " & aArrayOfArray(lngIndex1, lngIndex2) & vbcrlf
Next
Next
aFile.WriteLine(strArray)
End Function

'-------------------------
'Start of your VB script
'-------------------------
Dim myFSO
Dim myFile
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set myFile= myFSO.OpenTextFile("PadbVBScript.txt", 8, True)

Dim lPADBObject
set lPADBObject = CreateObject("IWebClientServ16.Profile","GMOBOSCRPAPP01R")
lPADBObject.setSqlServer = "GMOBOSCRPSQLR"
lPADBObject.formatOutput = True

Dim lRecordset
set lRecordset = CreateObject("ADODB.Recordset")
Dim lvRet
Dim lArray

set lRecordset = lPADBObject.getBenchmark(4004, "GMOBOSCRPSQLR")
myFile.WriteLine("<<>>")
WriteRecordSet lRecordset,myFile
myFile.WriteLine()

lvRet = lPADBObject.GetCountryWeights(1022,"8/31/2009","GMOBOSCRPSQLR",15,True)
myFile.WriteLine("<<>>")
WriteArrayOfArray lvRet,myFile
myFile.WriteLine()

lvRet = lPADBObject.GetChar(4002,"8/31/2009","GMOBOSCRPSQLR",,Array(4006),1)
lvRet = lPADBObject.toBaseCurrency(4002,"8/31/2009",lvRet,"GMOBOSCRPSQLR",True)
myFile.WriteLine("<<>>")
WriteArrayOfArray lvRet,myFile
myFile.WriteLine()

myFile.Close
set myFile = nothing
set myFSO = nothing
set lPADBObject = Nothing

VBS Functions

Monday, January 25, 2010

Finalize and Dispose

References:
Rules for Finalize and Dispose

Finalize and Dispose are all about freeing unmanaged resources such as files, streams, db connections etc. held by objects. While Dispose can be directly called by users of objects, Finalize is called by GC.

Do not assume Dispose will be called by the users/programmers using your object. You should always free up resources in Finalize as a back-up.

Calls must be propagated correctly through containmnet hierarchy i.e.
1. If object A has a reference to object B which in turn has reference to object C, then you must make sure that A.Dispose() code calls B.Dispose() (and B.Dispose() calls C.Dispose()).
2. A.Dispose() should also call A's base type's Dispose() if there is a base type implementing IDisposable.

When a class implements IDisposable, it is basically announcing it is using scarce resources. SAM: So your own object (whether stand-alone, abstract base or derived) can and should implement IDisposable, if it's holding references to unmanaged resources on its own or it contains objects that hold references to unmanaged resources. There is no reason why you can't implement your own IDisposable on an object that derives from another object that already implements that interface. However, depending on stand-alone, abstract or derived class you are coding, you may or may not have to implement your own IDisposable. Bottom line is, calling Dispose() by users should free up all the resources, containment-wise and object hierarchy-wise.

Close() should be a special case of Dispose(). Some unmanaged resources like streams have a state of either "open" or "closed", so it makes sense to provide a Close() method to the users of your class instead of Dispose(). However, calling Close() should internally call Dispose().




Example
==========

[C#]
using System;
using System.ComponentModel;

// The following example demonstrates how to create
// a resource class that implements the IDisposable interface
// and the IDisposable.Dispose method.

public class DisposeExample
{
// A base class that implements IDisposable.
// By implementing IDisposable, you are announcing that
// instances of this type allocate scarce resources.
public class MyResource: IDisposable
{
// Pointer to an external unmanaged resource.
private IntPtr handle;
// Other managed resource this class uses.
private Component component = new Component();
// Track whether Dispose has been called.
private bool disposed = false;

// The class constructor.
public MyResource(IntPtr handle)
{
this.handle = handle;
}

// Implement IDisposable.
// Do not make this method virtual.
// A derived class should not be able to override this method.
// SAM: Comment on "do not make this virtual". True only if the class you are
// writing is the base class like this example. However, a lot of times, you
// would be writing a class, derived from another class (your own or supplied
// by a software vendor) that DOES make this method virtual and rightfully
// so. Look at ActiveReports software example below.

public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}

// Dispose(bool disposing) executes in two distinct scenarios.
// If disposing equals true, the method has been called directly
// or indirectly by a user's code. Managed and unmanaged resources
// can be disposed.
// If disposing equals false, the method has been called by the
// runtime from inside the finalizer and you should not reference
// other objects. Only unmanaged resources can be disposed.
private void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if(!this.disposed)
{
// If disposing equals true, dispose all managed
// and unmanaged resources.
if(disposing)
{
// Dispose managed resources.
component.Dispose();
}

// Call the appropriate methods to clean up
// unmanaged resources here.
// If disposing is false,
// only the following code is executed.
CloseHandle(handle);
handle = IntPtr.Zero;
}
disposed = true;
}

// Use interop to call the method necessary
// to clean up the unmanaged resource.
[System.Runtime.InteropServices.DllImport("Kernel32")]
private extern static Boolean CloseHandle(IntPtr handle);

// Use C# destructor syntax for finalization code.
// This destructor will run only if the Dispose method
// does not get called.
// It gives your base class the opportunity to finalize.
// Do not provide destructors in types derived from this class.
~MyResource()
{
// Do not re-create Dispose clean-up code here.
// Calling Dispose(false) is optimal in terms of
// readability and maintainability.
Dispose(false);
}
}
public static void Main()
{
// Insert code here to create
// and use the MyResource object.
}
}






Active Reports Example
========================
Background info: From a client's standpoint, you call a method on a server
class "ProfileSummaryActiveReport" (which you also create but ultimately derive from
vendor's ActiveReports3 class) to render a report with "using". ActiveReport3 class
provides "virtual Dispose (bool disposing)" method. See how I have implemented my
client and server code to free up unmanaged resources and references to objects with
unmanaged resources. I could have implemented my own IDisposable on server class,
but I did not because I did not have to (since ActiveReport3 provided me the virtual
method to override).

Further, I architected "ProfileSummaryActiveReport" class to be simply a collection
of Activereports-provided SubReports. Each subreport is a ActiveReports-provided
tabular textual controls or it could be another vendor called ChartFX' chart control.

Idea is, when the client calls the method on ProfileSummaryActiveReport object
with "using", the Dispose() that fires should then propagate thru all objects in a
meaningful way i.e. call dispose() on each subreports.

//----------------------------------------------------------------------
Client calling

ProfileSummaryActiveReport lProfileSummaryActiveReport = null;
RenderReportResult lRenderReportResult = null;
using (lProfileSummaryActiveReport = new ProfileSummaryActiveReport(
aLogger,
lActiveReportCount,
lPageDataSet,
aReportParams,
pdfParams,
aProfileSummaryDiagnosticsInfo))
{
lRenderReportResult = lProfileSummaryActiveReport.RenderReport();
}

//----------------------------------------------------------------------
Servers

//Write your own server-based active report (must derive from vendor
//supplied class ActiveReport3) that serves as a container for subreports

public partial class ProfileSummaryActiveReport : ActiveReportBase
{
public List ListOfSubReportWrapper = new List();

public List ListOfPlaceholderSubReportWrapper = new List();

private void DisposeSubReports()
{
foreach (SubReportWrapper lSRW in this.ListOfSubReportWrapper)
{
lSRW.ARSubReport.Dispose();
}

foreach (SubReportWrapper lSRW in this.ListOfPlaceholderSubReportWrapper)
{
lSRW.ARSubReport.Dispose();
}
if (this.ReportPageFootnotes != null)
this.ReportPageFootnotes.Clear();

if (this.SubReportForcedHeightInfoList != null)
this.SubReportForcedHeightInfoList.Clear();

foreach (KeyValuePair lKVP in this.mDictionaryProfileSummarySubReport)
{
if (lKVP.Value.SubReportDataSet!=null)
lKVP.Value.SubReportDataSet.Dispose();
}
}


//blah blah
}

partial class ProfileSummaryActiveReport
{
///
/// Clean up any resources being used.
///

protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.mReadyToDisposeSubReportsIfAny)
{
this.DisposeSubReports();
}
}
base.Dispose(disposing);
}

private DataDynamics.ActiveReports.Detail detail;
//blah blah
}

//----------------------------------------------------------------------

public partial class ActiveReportBase : DataDynamics.ActiveReports.ActiveReport3
{
protected System.Data.DataSet mReportData = null;

public byte[] CombineReportsAsPDFByteArray(Dictionary aDictionaryOfReports)
{
DataDynamics.ActiveReports.ActiveReport3 lActiveReport = new ActiveReport3();
int lPageNumber = 0;
foreach (KeyValuePair kvp in aDictionaryOfReports)
{
lPageNumber++;
using (MemoryStream lMemoryStream = new MemoryStream(kvp.Value))
{
this.Document.Load(lMemoryStream);
foreach (Page lPage in this.Document.Pages)
{
lActiveReport.Document.Pages.Add(lPage);
}
}
}

using (MemoryStream lMemoryStream = new MemoryStream())
{
using (PdfExport lPdfExport = new PdfExport())
{
lPdfExport.Export(lActiveReport.Document, lMemoryStream);
}
lMemoryStream.Flush();
lActiveReport.Dispose();
this.mReadyToDisposeSubReportsIfAny = true;
return lMemoryStream.ToArray();
}
}

//blah blah
}

partial class ActiveReportBase
{

///
/// Clean up any resources being used.
///

protected override void Dispose(bool disposing)
{
if (disposing)
{

}
base.Dispose(disposing);
}

private DataDynamics.ActiveReports.Detail detail;
//blah blah

}

//----------------------------------------------------------------------

public partial class GanttChartFX : ProfileSummarySubReportARBase, IBarBasedChart
{
private ChartFX.WinForms.Chart mChart = null;
private DataDynamics.ActiveReports.CustomControl mCustomControl = null;

//blah
}

partial class GanttChartFX
{

///
/// Clean up any resources being used.
///

protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.mChart != null)
this.mChart.Dispose();

if (this.mCustomControl != null)
this.mCustomControl.Dispose();
}
base.Dispose(disposing);
}

private DataDynamics.ActiveReports.Detail detail;
// blah
}

//----------------------------------------------------------------------

public abstract partial class ProfileSummarySubReportARBase : DataDynamics.ActiveReports.ActiveReport3, IProfileSummarySubReportRenderer, IPlaceholderSubReportHost
{
// blah
}

partial class ProfileSummarySubReportARBase
{

///
/// Clean up any resources being used.
///

protected override void Dispose(bool disposing)
{
if (disposing)
{
}
base.Dispose(disposing);
}

private DataDynamics.ActiveReports.Detail detail;
// blah
}

Monday, January 11, 2010

Total Recorder Drivers - 3 kinds

Total Recorder Drivers

Sam: When recording from internet radio,

(1) go to TR's recording source and parameters and make sure you choose "software" instead of "sound board" for audio recording source.
(2) go to TR's settings->Driver, choose "Kernel-mode filter driver" and "any playback device" under playback and recording.


Selecting the type of driver to be installed with Total Recorder

Total Recorder has three types of audio drivers:

User-mode virtual device driver. This is the same type of driver that has been supplied since the first version of Total Recorder.
Kernel-mode virtual device driver, which was added in version 7.0.
Kernel-mode filter driver, which was added in version 8.0.
When installing Total Recorder, you can select any combination of Total Recorder drivers to be installed, or you can select not to install a driver. It is recommended you choose one of the following configurations during installation:

Simple configuration.

Install Total Recorder with the kernel-mode filter driver only.
This configuration is suitable in most cases because of its ease-of-use, an absence of undesirable effects due to additional drivers, and the main features of software recording, except for accelerated and silent recording, can be used.
Advanced configuration.
For Windows XP:
Install Total Recorder with the user-mode driver and the kernel-mode filter driver.
For Windows Vista and later:
Install Total Recorder with both the kernel-mode drivers (virtual device driver and filter driver).

This configuration provides the ability to use almost all of the features of software recording. More complex Total Recorder settings may be required especially if several sound devices are used.
Restricted configuration
Install Total Recorder without a driver.
If you install Total Recorder without a driver, you will not be able to record in Software mode. An alternative to Software mode recording is to record in Soundboard mode from a line such as "Stereo Mix", "Wave", "What U hear", or similar. Most sound boards have such a line. Installing Total Recorder without a driver may be necessary if you encounter compatibility problems between the Total Recorder drivers and other software.

If you install Total Recorder with more than one driver, you can select which driver Total Recorder uses.

To install or uninstall a driver, you must reinstall Total Recorder over the installed instance and select the appropriate driver options during installation. All of Total Recorder's settings and registration information are preserved except for any settings that are incompatible with the new driver's configuration.

Comparing Different Types of Total Recorder Drivers
User-mode virtual device driver

Advantages
Sound is captured exactly in the same format that is used by an audio player to pass audio data to a sound board.
Sound can be captured from specific applications.
Accelerated recording is faster and more reliable.
Disadvantages
This type of driver is not fully supported by modern operating systems. For Windows XP, you may find incompatibilities with some applications. For Windows Vista and later operating systems, most applications cannot be recorded with this driver. See information below.
Kernel-mode drivers (virtual device driver and filter driver)

Advantages
These drivers are fully compatible with modern operating systems.
The kernel-mode filter driver does not require any change to your system audio settings.
Disadvantages
Sound is captured after it has been processed (mixed, resampled) by the operating system. This results in the following:
- You cannot restrict recording to a particular application.
- Additional conversions of the format may be performed.
- Volume regulators can affect the sound being captured.

Accelerated recording through the kernel-mode virtual device driver is slower and less reliable. Accelerated recording through the kernel-mode filter driver cannot be done at all.
You may experience other problems. For more information, see below.
Advantages of the kernel-mode filter driver over the kernel-mode virtual device driver

The kernel-mode filter driver does not add a sound device in your system whereas the kernel-mode virtual device driver does. When using the kernel-mode filter driver, no special configuration of system audio devices or devices used by a program to be recorded is required.
The kernel-mode filter driver does not result in problems with USB microphones on Windows XP.
Advantages of kernel-mode virtual device driver over the kernel-mode filter driver

The kernel-mode virtual device driver can record in accelerated mode and in silent mode.
If the kernel-mode virtual device driver is used, usually you can configure your system and sound applications so that only the application’s sounds will be recorded. If the kernel-mode filter driver is used, recording a particular application can be achieved only if there is more than one real sound playback device on your system.
After installing the kernel-mode filter driver, a reboot is always required. After installing the kernel-mode virtual device driver, a reboot is not usually required.
Possible Problems with Total Recorder Drivers

Possible problems with Total Recorder's user-mode driver
- Incompatibility with DirectSound

Problems can occur with an application that uses Direct Sound. If such an application passes a sound stream through the driver, the sound may be garbled. For example, distortions often appear when using most versions of Skype 3.x.

- Incompatibility with a small number of applications

A small number of applications may not start at all, or they may function incorrectly, if the driver is set as a system default device. Examples of such applications include CyberLink software (e.g. PowerDVD, PowerProducer) and Adobe software (e.g. Adobe Premiere, Adobe Encore, etc.).
- Partial compatibility with Windows Vista

See this information regarding compatibility issues between the user-mode driver and Windows Vista.
Possible problems with Total Recorder's kernel-mode driver (virtual device driver or filter driver)

- Unable to record a particular application

The system mixes audio streams being played before it arrives in the kernel-mode driver. Audio streams being played can only be recorded in mixed form. This is similar to recording from a line such as "Stereo Mix". It is not possible to single out a stream belonging to a particular application as it could be made using a user-mode driver. All appropriate recording parameters (i.e. Record only streams opened after the recording has started and Record only this application) are disabled.
- Volume regulator affects the level of recording

The volume level of the Wave line affects the level of sound received by the kernel-mode driver. For quality recordings, it is recommended you set the volume level of the Wave line to the maximum position and do not change this level during the recording. You should use the level of the Master line to regulate the sound volume when recording.

Notes:

Most players' volume regulators are connected to the Wave line. You should set the regulator to the maximum position and do not change it during a recording.
The system volume regulator, which is the regulator that appears when you click on the system tray icon, is associated with the Master line. You can adjust it freely while recording.
Under Windows XP, you can also use the volume regulator in Total Recorder's main window to adjust volume. Beginning with version 7.0, this regulator is associated with the Master line rather than the Wave line. Under Windows Vista, you should use only the system volume regulator.
- Accelerated recording through the kernel-mode filter driver cannot be performed

If Total Recorder is set to use the kernel-mode filter driver then Total Recorder cannot record in accelerated recording mode.
- Additional format conversion is sometimes performed

When a playback program passes a sound stream to the sound board, Windows can transform this sound stream to a format supported by your sound board. Total Recorder's kernel-mode driver receives this transformed stream rather than the original stream. The driver does not know the format of the original stream and Total Recorder can display only the format of the transformed stream.

In very rare cases, this conversion can result in a minor loss of quality, although this loss is normally not audible. Since the majority of recordings are performed in a compressed format, the compression results in more loss in quality (even if it is usually not audible) than the conversion.

Possible problems specific to Total Recorder's kernel-mode virtual device driver
- For some sound boards, a sound stream cannot be played through the board while another stream is played through the kernel-mode driver if the driver is set to use the sound board

This restriction can cause some problems:
If an application plays silence continuously and the application cannot be closed, then switching a system default device may require you to restart your system or to log off and on before your sound program will work properly.
You cannot record a particular sound stream by directing the stream to Total Recorder's kernel-mode driver while directing all other sound streams to the real sound board.
Note that this problem does not occur with most sound boards.
- Incompatibility with USB-microphones under Windows XP

Total Recorder's kernel-mode driver does not work with USB microphones under Windows XP. This can result in problems when recording an Internet telephony program, such as Skype. Such programs can be recorded, however this requires some additional setup. For more information, see Total Recorder Help: Troubleshooting -> After installing Total Recorder with the kernel-mode driver, problems occur using a USB microphone.

Note that this problem does not occur on Windows Vista.
- Problems with accelerated recording

The speed of an accelerated recording can be lower when using the kernel-mode driver compared with the user-mode driver. The recorded sound may be garbled even though no problems appeared when the recording was being made. For more information, see Total Recorder Help: Using Total -> Recorder Recording -> Accelerated Recording.
- Driver's recording-level regulator may function improperly

It is possible that the recording level regulator or the volume for specific playback lines of the driver does not work. This depends on the particular sound board. If you encounter this problem, follow these recommendations:
For Windows 2000/XP: Launch the system mixer, and use the controls of the real sound board rather than the controls of Total Recorder's driver.
For Windows Vista: From the Control Panel, click Sounds (or select Options - System settings in Total Recorder's main menu), select the playback or recording device to be used, click the Properties button, and then go to the Levels tab.
- Under Windows 2000/XP, if you record from Total Recorder's kernel-mode driver device, you should manually select the recording line

Total Recorder's kernel-mode driver has only one recording line, called "Microphone". Recording actually occurs through the active recording line of a real sound board. If you find that a recording uses an incorrect line, you should manually select the proper recording line by using the system mixer.
This problem occurs mostly when recording Internet telephony programs, such as Skype. If you only want to record from a sound board, you should record directly from a real sound device rather than from Total Recorder's driver.
- Under Windows Vista, if you record from Total Recorder's kernel-mode driver device, the recording can use an incorrect line

If you use Total Recorder's kernel-mode driver to record from a recording device, sometimes the recording uses an incorrect line. This problem depends on the real soundboard driver.
This problem occurs mostly when recording Internet telephony programs, such as Skype. If you only want to record from a sound board, you should record directly from a real sound device rather than from Total Recorder's driver.
If this problem occurs, take the following steps:
Stop using the recording device, and terminate the Internet-telephony conversation.
From the Control Panel, click Sounds (or select Options - System settings in Total Recorder's main menu), and then go to the Recording tab.
Select a real device (normally a microphone) that should be used for capturing sound, and click the Set Default button
Select Microphone. Total Recorder kernel mode (WDM) audio driver, and click the Set Default button.

Close the Sounds window.
See also:

Primer on PC Audio

Thursday, January 7, 2010

SQL Server UDTs

Msg 2715, Level 16, State 7, Procedure SPregInsertRegressionTop1Report, Line 70
Column, parameter, or variable #1: Cannot find data type DTObjectID.

Above error ocurred on CRPCORE db on my local computer. The UDT DTObjectID does exist in db CRPCORE (under Programmability.Types.User-defined Data Types).

Problem: UDTs must be known to SQL server before they can be used i.e these UDTs must also exist in model and tempdb databases. Im my case, esp tempdb because the SP above internally creates a table (with create TABLE) which, as we all know, gets created in tempdb.

Resolution: import these UDTs to model and tempdb.

Monday, January 4, 2010

drop database

-- drop kick any connections to database "foo" and roll back their transactions
ALTER DATABASE foo
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE

-- Drop the database "foo"
USE MASTER
GO

DROP DATABASE foo

Thursday, December 31, 2009

SCHEMA

SCHEMA
=========

-----------
USER "A"
-----------

--owns--> SCHEMA "S1"

--contains--> SP_1

<--owns-- DB_ROLE "R"

--owns--> SCHEMA "S2"

--contains--> TABLE_1

<--owns-- USER "B"

--owns--> SCHEMA "S3" --contains--> VIEW_1 <--owns-- USER "B", DB_ROLE "R"


-----------
USER "DBO"
-----------

--owns--> SCHEMA "DBO"


----------------
USER "DB_OWNER"
----------------

--owns--> SCHEMA "DB_OWNER"


----------------
DB_ROLE "R"
----------------

--owns--> SCHEMA "S2"

--contains--> TABLE_2

--owns--> SCHEMA "S3"

--contains--> VIEW_2


Schema can only contain certain entities, namely OBJECT (tbls, views, SPs, functions, queues and synonyms are objects that are "ownership-transferable" while other objects like linkedsrvrs, constraints, rules, triggers, credentials, statistics etc. are not), TYPE and XML SCHEMA COLLECTION.


**The only reliable way to find the owner of a object is to query the sys.objects catalog view. The only reliable way to find the owner of a type is to use the TYPEPROPERTY function.



A schema contains database (catalog) objects such as tables, views and SPs. A schema owner may be a DB user, DB role or app role.


DB user has one to many relationship with dbo schemas i.e. a schema can belong to only one user while a user can own many schemas.


"dbo" exists as a default schema. "dbo" also exists as a DB user. By default dbo user owns dbo schema.

"db_owner" is also both schema and user. So are other db_*,INFORMATION_SCHEMA etc. In fact, it is tempting to create the same schema name for every DB user. Is that a good practice?

Beginning with SQL Server 2005, a user can own an OBJECT or TYPE that is contained by a schema owned by another database user.

Wednesday, December 16, 2009

Recipe: pumpkin soup w/o pumpkin

1 Onion
2 Potatoes
1 cup cream
1 jar of maple pumpkin butter

Satay chopped one white onion with olive oil.
Throw in 2 chopped potatoes.
After being somewhat cooked, blend until smooth.
Pour back to pan, add a cup of cream and a whole jar of MAPLE PUMPKIN butter.

Tuesday, November 24, 2009

XML Serializer: How to omit namespace and other redundant info

public static string SerializeType(Type aType, object aObject)
{
XmlSerializerNamespaces lXmlSerializerNamespaces = new XmlSerializerNamespaces();
lXmlSerializerNamespaces.Add("", "");
XmlSerializer lXmlSerializer = new XmlSerializer(aType);
XDocument lXDocument = new XDocument();
using (XmlWriter lXmlWriter = lXDocument.CreateWriter())
{
XmlWriterSettings lXmlWriterSettings = lXmlWriter.Settings;
lXmlWriterSettings.OmitXmlDeclaration = true;

lXmlSerializer.Serialize(lXmlWriter, aObject, lXmlSerializerNamespaces);
lXmlWriter.Close();
}
return lXDocument.ToString();
}

Thursday, October 1, 2009

Write Dataset to XML with WriteSchema

Serializing dataset ignores empty datatables

When you call lDataSet.WriteXml(aXMLFilePath), any data table without rows will be ignored. To include it (because table schema may still be important), use the WriteXml overload that writes to an xmlWriter and enable"WriteSchema".

I use XDocument that can create XmlWriter but I'm sure there are other ways.

XDocument lXDocument = new XDocument();
using (XmlWriter lXmlWriter = lXDocument.CreateWriter())
{
lMasterDataSet.WriteXml(lXmlWriter, XmlWriteMode.WriteSchema);
}
lXDocument.Save(@"c:\temp\PSReportServer_MasterDataSetWithSchema.xml");




Saturday, September 26, 2009

how to enumerate enum?

internal enum ChartRendererTypes
{  TabularTextual,  GanntChartFX }
foreach (ChartRendererTypes suit in Enum.GetValues(typeof(ChartRendererTypes)))
{
}

Thursday, September 24, 2009

Debugger issues

Debugger cannot start if

Protected ReadOnly Property Logger() As ILogger
Get
CreateLogger()
Return mLogger
End Get
End Property

Why? This is not good. First, this property is intended to be get only, not set so VB requires adding ReadOnly key. Fine so far! But CreateLogger() is a function call that ensures mLogger comes out alive i.e. if mLogger is not already instantiated, then the function instantiates it, sets to specific log file etc. But we cannot test that, the VS debugger does not like that function and just simply says the debugger cannot be started! The release version bombs as well and prompts you with that dialog box asking if you want to see the error with a debugger (however, I noticed the dialog had VS2003 debugger!! I'm using VS2008 IDE!!)

Solution: Write "Me.CreateLogger()"

Saturday, September 12, 2009

Samsung 4500W printer info

Support

Things like how to scan using Scan Thru, where to buy a toner etc.

Should be able to see the printer's own website (thru a web service). Just type in its IP address as set up by DHCP router.

Ctrl panel should have Samsung Scan Manager thru which you can quick scan also - may need to set up the IP there though.

Friday, July 31, 2009

Scripting

Powershell
http://powershell.com/Mastering-PowerShell.pdf

Muse

on seemingly promising stock rally
==========================
it's not green shoots. It's an assisted form of convalescence.
it's contrived from less-than-desirable cost-cutting measures.

Tuesday, July 14, 2009

DataSet Related

Copying a datatable
===============
When trying to add a datatable to a dataset and you get an error saying datatable belongs to another dataset, then do this: Set a new copieddatatable = origdatatable.copy(). You should be able to add the new copieddatatable to the dataset.

Saturday, June 20, 2009

sponsored web search

http://research.microsoft.com/pubs/74046/ICDE2009.pdf

Friday, June 12, 2009

Calculate font width with GDI+

http://www.eggheadcafe.com/community/aspnet/2/10911/heres-a-sample.aspx

public Bitmap Render()
{

Graphics g = Graphics.FromImage(_canvas); //painting surface. uses canvas.

Font font = new Font(_font, _fontStyle);

SolidBrush shadowBrush; //for painting text
SolidBrush textBrush;

int nCharsFitted; //this is how we know we have all of the characters on the canvas
int nLinesFilled; //this tells us how many lines the text uses

//antialias fonts.
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

//create new canvas and set the size
Size canvasSize = _canvas.Size;
SizeF canvasSizeF = new SizeF(_canvas.Width, _canvas.Height);

//specify formatting options
StringFormat stringFormat = new StringFormat();
stringFormat.FormatFlags = StringFormatFlags.FitBlackBox & StringFormatFlags.NoClip;
SizeF textSizeF = new SizeF(0,0);

//fit text
while (true)
{
//measure text
textSizeF = g.MeasureString(_zText, font, canvasSizeF, stringFormat, out nCharsFitted, out nLinesFilled );

//see if it fits
if ((canvasSizeF.Height >= textSizeF.Height) &
(canvasSizeF.Width >= textSizeF.Width) &
(nCharsFitted == _zText.Length) &
(nLinesFilled * font.Height <= canvasSizeF.Height)) { //text fits break; } else { //text doesn't fit. lower point size and try again. font = new Font(font.FontFamily, font.SizeInPoints - 1, font.Style); } } //set point for where to start drawing the text PointF textPoint; PointF shadowPoint; switch(_eAlignment) { case Engine.Imaging.Alignment.Center: textPoint = new PointF((canvasSizeF.Width - textSizeF.Width) / 2, 0); break; case Engine.Imaging.Alignment.Right: textPoint = new PointF(canvasSizeF.Width - textSizeF.Width, 0); break; default: textPoint = new PointF(0,0); break; } //apply shadow? if (_nShadowDepth > 0)
{
shadowPoint = new PointF(textPoint.X + _nShadowDepth, + _nShadowDepth);
shadowBrush = new SolidBrush(_shadowColor);
g.DrawString(_zText, font, shadowBrush, new RectangleF(shadowPoint , canvasSizeF), stringFormat);
}


//define brush with color to paint text with
textBrush = new SolidBrush(_textColor);

//apply text
g.DrawString(_zText, font, textBrush, new RectangleF(textPoint , canvasSizeF), stringFormat);


textBrush = null;
shadowBrush = null;
g = null;
stringFormat = null;

return _canvas;
}

Another one
http://social.msdn.microsoft.com/forums/en-US/vblanguage/thread/8b301d31-5b2c-4c6d-b78f-c0867dd0084e

Monday, June 1, 2009

Random Health and Food Topics

Spicy food like curry may help fight brain cancer. Also first ever vaccine may be in the works. Here's the story on extratv.

Saturday, May 30, 2009

Down to quantities

References

healthy diet fit body

Per day

to fight hypertension and high blood pressure

fruits and vegetables in general are the best.

increase potassium - 4700 mg : bananas, potatoes (no, you can’t have french fries), canned white beans, yogurt, halibut, tuna, lima beans and winter squash

reduce sodium (most important for reducing hypertension, others are secondary) - 2300 mg (approx 1 tablespoon) : salty snack eaters eat 4X as much while average americans eat 2X as much

magnesium - 500 - 1000 mg: in a well-bal diet.

(increase) calcium - 800 - 1000 mg: average american gets half. Take supplement with 3-400mg.

** Vitamin D **

People have not figured out on D!! Just read this on WebMD and on MSN Health, and you will see that the experts have no freaking clue as to HOW MUCH D we need. Ask my doctor if I need to take D. I was going to order D supplements (since thru diet, getting 2000IU is almost impossible?) but I'm hesitant now. More info needed...

For me, I figure about 2000 IU (dark skinned, not enough sun exposure). Get this thru supplement since D is hard to get from food and since sun is not always available.

The U.S. Recommended Dietary Intake for vitamin D is currently 400 International Units (IU). However, research is suggesting that may not be enough. In fact, a recent study in the American Journal of Clinical Nutrition suggests that doses of 3,800 to 5,000 IU may be needed to maintain optimal blood levels, as the body doesn't absorb all it takes in. The official safe upper-limit (UL) for vitamin D intake is 2,000 IU, although many researchers are now saying this is much too conservative and it should be reset to 10,000 IU. However, scientific organizations are slow to change their recommendations, so it may be a while before the official UL is reset to a higher level.

A minimum of 1,000 IU every day is recommended. Keep in mind if you're overweight or dark-skinned, you are at a high risk for deficiency.

One cup of fortified milk has only 100 IU of vitamin D (we actually get much more vitamin D from the sun than we could ever get from food).

If you expose your face, arms, back, or hands to the sun three times per week for 15 minutes between 11 a.m. and 2 p.m., you'll get a dose of about 3,000 IU of vitamin D. So, before you slap on the sunscreen, give yourself this small amount of sun exposure. Then, you can put on the sunscreen to avoid over-exposure to the sun.

Heart disease prevention

maintain body weight
exercise
low saturated and trans fat
high omega3 fatty acid
keep LDL below 100, HDL over 40
be happy

Whey protein
.7 * body wt of about 150 = 105 gm of whey (too much??)
still sounds too much. taking 20g scoop 4 times already sounds enough.
space it out daily so liver/kidney is not overworked
isolate form is better but more expensive, mix of isolate and concentrate (higher % of isolate though) gives you biggest bang for buck

What to eat before during after excercise?
after exercise, only 10-20g of protein says this article!!

Saturday, May 23, 2009

abs workout

best abs workout - most with no tools

best abs workout take 2

long arm weighted crunch - with light dumbells on each hand and lying flat with knees bent

youtube at home crunch

youtube ** good review

What's in a breakfast?

Why breakfast is important?

Cereals are just "better than nothing". If u must, look for whole grain, add >5g of daily fiber, <25% sugar calories.

Vitamin D, Fish Oil, Vitamin E etc.