Monday, 28 March 2016

Export Word Doc to PDF with Word for iPad

In the Word document:
  • Click the Share (right) icon (the one with a person and a + sign)
  • Select "Send Attachment"
  • Select "PDF"
  • Select "Send a Copy"
  • Here I found a few useful options, send to Google Drive (may need to click "More" to enable it), Gmail and "Save to Dropobox", etc.

Friday, 18 March 2016

iPad connects to weak WiFi network

I found one very interesting fact... my work place has a very weak public WiFi.  My iPad normally doesn't able to see and connect to it.  But once I connect a Bluetooth device (either my MacBook Air or even just a bluetooth keyboard), I am able to connect to this WiFi network.

Thursday, 25 February 2016

Uninstall / Remove FxFactory Product

  • Start FxFactory (5.0.9)
  • Actions >> Show Products in Finder
  • It will show two windows
    • Users>'user name'>Library>Application Support>FxFactory
    • Library>Application Support>FxFactory
  • Move the product to the Trash (type in your password)
    • Normally, it will have more than one files
  • It will disappear right away in the Installed tab

Thursday, 18 February 2016

How to Use Exposure Compensation to Take Control of Your Exposure

http://digital-photography-school.com/how-to-use-exposure-compensation-to-take-control-of-your-exposure/

  • Aperture Priority Mode – In Aperture Priority mode, exposure compensation changes the shutter speed. Remember that in this mode, you set the aperture and the camera sets a corresponding shutter speed. If you change the Aperture, your camera just sets another corresponding shutter speed, and there is no change in the exposure level. Exposure compensation gives you the ability to change the shutter speed (and the overall exposure value) while staying at the same aperture you originally set.
  • Shutter Priority – In Shutter Priority mode, exposure compensation changes the size of your aperture. It is basically the reverse of Aperture Priority mode. You set a shutter speed, and the camera sets a corresponding aperture. Exposure compensation therefore changes the exposure by allowing you to change that aperture size.

Wednesday, 17 February 2016

Thursday, 11 February 2016

Intro to Unreal Engine for VR

https://channel9.msdn.com/blogs/misslivirose/Intro-to-Unreal-Engine-for-VR


Monday, 18 May 2015

Excel on Mac/Windows - linebreak in cell

On Mac - control-option-return
 
On Windows - alt-return (or alt-enter)

Saturday, 2 May 2015

Setup HP ProLiant ML310e Gen8 v2 Server - Install OS (Windows Server) with Intelligent Provisioning

I have the Windows 2012 R2 installation on USB drive.  I have installed a single 320GB HD.  I boot up the server but cannot from the USB to install the OS, some driver(s) will not be available.
  • Start the server
  • Press <F10> to Start Intelligent Provisioning (when the options are shown)
  • Click on "Configure and Install"
  • Step 1 Hardware Settings, Continue (use default)
  • Step 2 OS Selection (select the OS, Install Method and Source Media), Continue
    • the Source Media options
      • Disc
      • Network Share
      • FTP
      • USB
  •  Locate OS installation File, Continue
    • For USB, open usb-sdb1
  • OS Info
    • Enter Admin Password (optional)
  • Continue to start the installation
    • Update firmware
    • Copy OS files
  • Reboot
  • OS Installation
  • Restart a few times




Thursday, 23 April 2015

Lightroom Presets

Installing new presets

  • Start Lightroom
  • Open up the presets on the left (in Develop mode)
  • All the adobe presets start with "Lightroom ..."
  • Create new folder for the new presets (optional), otherwise, lightroom will put new presets in "User Presets" folder.  This is your way to group the presets.
  • Right click on the folder and select "Import"
  • Go to the location of your downloaded presets and import them (remember to unzip the zip file to get the preset files .lrtemplate)
  • You can move the preset from one folder to the other
  • Right click on the imported preset and select "Show in Finder"
  • You can import the new presets, create new folder from here (need to restart Lightroom to see the result)
  • You cannot create sub-folders and if you create sub-folder manually in the finder, the sub-folder will appear as a folder in lightroom

Free Presets

  • http://seimeffects.com/2011/11/04/silver-shadows-2-free-lightroom-presets/
  • http://www.presetsheaven.com/presets/28-free-lightroom-presets-from-chris/
  • http://www.deliciouspresets.com/shop/lightroom-presets/free/

Tuesday, 21 April 2015

Tips for using Oracle (for beginner)

Useful SQL statements

get all the tables

SELECT * FROM TAB ORDER BY TNAME

get all the columns 

select * from col where tname = '<table name>' ORDER BY colno

Return Top n records (Select Top 1 * in MS SQL)

SELECT column_name(s)
FROM table_name
WHERE ROWNUM <= number;

Concatenation Operator 

  • ||

IF THEN ELSE ELSIF END IF example

     IF (...) THEN
          ...;
     ELSIF (...) THEN
          ...;
     ELSE
          ...;
     END IF;

GetDate() (in MS SQL)

  •     sysdate

Table DUAL

A dummy table with a single record used for selecting when you're not actually interested in the data, but instead want the results of some system function in a select statement:

  •     select sysdate from dual;

Sequence

Open
to see the defination (Last number too)
Get next value
<sequence_name>.NEXTVAL;

INSERT INTO <table>
(<col1>, <col2>)
VALUES
(<seq_name>.NEXTVAL, 'xxx');

you can't use CURRVAL until you have used NEXTVAL at least once in your session.

Data Types

No boolean data type
varchar2 (2K, Oracle8 4K)
number(5,2) - 999.99

Terminology


TerminologyOracleSQL Server

schemadatabase

service namedatabase name

System ID (SID)database name
Storage blockpage
Extentuser-definedfixed at 8 pages
Storage management pages (SMP)dictionary or locallocal only
Metadatadata dictionarySYS database
Recursive SQLconnect by clauseHierarchyID data type
LanguagePL/SQLT-SQL

For Loop and with / as a Cursor

FOR i IN 1..10
LOOP
...
END LOOP;

--------------------------------
FOR iRec IN (SELECT * FROM <table> WHERE <field> = <value>)LOOP
...
END LOOP;

--------------------------------
CURSOR <cursor name> IS
    <sql statement>

BEGIN
    FOR <item> IN <cursor name>
        LOOP
            ...
        END LOOP;
END;

--------------------------------
can pass a parameter:

CURSOR <cursor name> (<parameter> VARCHAR2) IS
    <sql statement>
BEGIN
    FOR <item> IN <cursor name>(<parameter>)
        LOOP
            ...
        END LOOP;
END;

 

Wednesday, 21 January 2015

Challenges of Life

"Great faith is a product of great fights. Great testimonies are the outcome of great tests. Great triumphs can only come out of great trials" - Smith Wigglesworth.

Sunday, 18 January 2015

iPad Air Lightning to HTMI adaptor

If you have problem with the Apple Lightning To Hdmi Cable, try to plug it in the other way.  I found that I need to plug it upside down.


l1000.jpg

Monday, 8 December 2014

Photography - Close up

Don't cut off body parts except at the mid chest, waist or mid thigh region.

http://www.izzyvideo.com/close-up-shot/

  • medium close up (MCU) - cut at waist, show hands movement, with head room above the head
  • close up (CU) - at the chest, with head room
  • head and shoulder close up
  • head close up (big head close up)
  • choker close up - the face only
  • extreme close up - the mouth only

Sunny 16 rule

If it's a sunny day, set aperture to f/16 and shutter speed closest to the reciprocal of yout ISO.

  • ISO 50, 1/60 sec
  • ISO 100, 1/125 sec
  • ISO 200, 1/250 sec, etc.


Use f/16 for sunny settings, but go down for less bright conditions:

  • f/11 for cloudy daylight
  • f/8 for overcast
  • f/5.6 for outdoor shade
  • f/4 for dark shade


Thursday, 4 December 2014

Dos and Don’ts for Shooting the Moon

Wednesday, 3 December 2014

Five Things You Don’t Need To Include On Your Resume

  • Every Job You’ve Ever Held
  • Starting and Ending Months for Your Past Positions
  • Your Tasks and Duties at Each Job
  • Your Exact Job Title, If It’s Confusing
  • Any Indication of Your Age

http://news.monster.com/a/other/five-things-you-dont-need-to-include-on-your-resume-33cc5d?WT.mc_n=CRM_US_B2C_LC_JOM_Act_D_141203


Thursday, 9 October 2014

Remove MS SQL Server Instance

This is the example in Windows 7 with MS SQL Server 2012
  • Control Panel
  • Program and Features
  • Select "Microsfot SQL Server 2012 (64-bit)"
  • Click "Uninstall/Change"
  • Click "Remove"
  • Click "OK"
  • Select the instance to remove in the drop down box, click "Next >"
  • Check the features (will show all available features installed for this instance) to remove
    • Database Engine Services
    • Reporting Services, etc.
  • Click "Next >"
  • Click "Next >"
  • Click "Remove"
  • Click "Close"

https://www.youtube.com/watch?v=ugkP3Wt850c

Sunday, 5 October 2014

Getting Mac OS version in a disk image

You can get the version in this file:
  • /System/Library/CoreServices/ServerVersion.plist
    • <key>ProductUserVisibleVersion
      • <string>

Sunday, 28 September 2014

Custom Thumbnail for YouTube video on a Mac

Instead of using the default three thumbnails from YouTube, you can use any part of the video as the thumbnail:

  • Play the video using any player stop at the spot you want it as the thumbnail
  • Press <command><shift>4 and then <spacebar>
  • Click on the player window 
  • Save the image on DropBox (optional, but very handy)
  • Upload to YouTube

Tuesday, 23 September 2014

6 Ways to Take WOW Photos in Less Than an Hour

In summary:

  • Method One: Bird’s Eye View
  • Method Two: Worms Eye View
  • Method Three: Shoot at an Angle
  • Method Four: Get the Sun Behind Your Subject
  • Method Five: Use Shadows
  • The Ultimate WOW Shots
    • The ultimate WOW shots are created when you use one of more of these techniques by combining elements, angles, and points of view.

http://digital-photography-school.com/6-ways-to-take-wow-photos-in-less-than-an-hour/

Ten must have camera settings for Concert Photography

Here is a summary of the ten must have camera settings:

  1. Use manual exposure mode
  2. Use your lowest aperture number
  3. Use fast shutter speeds
  4. Use high ISO values
  5. Use spot metering
  6. Use your middle autofocus point
  7. Use the auto white balance setting
  8. Use burst mode
  9. Never use flash
  10. Shoot in RAW format
http://digital-photography-school.com/10-must-have-camera-settings-for-concert-photography/

Thursday, 7 August 2014

VS 2005 Open Debug Immediate window

Shortcut <Ctrl><Alt><I>

If you cannot find it anywhere in the menu (Debug),

  • go to Tools
  • Customize...
  • Commands tab
  • Categories: Debug
  • Drag and droop Immediate to the menu (e.g. Debug)


Wednesday, 29 January 2014

Windows 7 Stereo Mix

If you want to record whatever it is playing on your computer, there is a simple way to do it.
  • Right click on the "Speakers" from the Task Bar 
  • Select "Recording devices"
  • Right click in the tab and check "Show Disabled Devices" (if it is not checked)
  • Right click on "Stereo Mix" and select "Enable"
Use any recording software such as Audacity and select "Stereo Mix" as your input device.


Tuesday, 28 January 2014

APS Daemon - missing MSVCR80.dll

Uninstall all Apple applications and reinstall iTune will fix this problem.


Monday, 20 January 2014

Word of God

The Word of God inflicts hurt on us more than sin ever could, because sin dulls our senses.

The Basics of Video Compression

Why Do We Compress the video?

  • An uncompressed 1080p file requires about 237 MB/second for playback.  
    • It is far exceeding any internal connection speed mere mortals can afford.  
    • Most compressed movies playback from the web at less than 1.5 MB/s
  • The higher the quality of the source file, the higher the potential quality of the compressed files derived from it.
    • You can't make a compressed file look better than the source file; with the possible exception of making the frame size smaller.
  • When compressing a file, you apply settings to determine what you want the source file to become.
    • The size and format of the source file have almost no relevance.
    • all compression software automatically determines the specs of the source file and creates the transcoded file based on your settings.

Definitions

Codec (Compressor/Decompressor)
The mathematics used to convert light and sound into numbers that can be stored and played back from a computer.  Codecs are the heart and soul of compression.  There is no single codec that is perfect for capture, editing, and distribution.

Bit rate
The speed, in bits per seconds (bps), of a media file during playback.  Controlling bit rate is a key element of compression.  Also called data rate or bandwidth.  This also determines how smoothly a web video will stream.
Our Goal, when creating videos for the web, is to get the highest possible image quality from the smallest possible bit rate.

Frame size
The size, in pixels, of a video frame

Frame rate
The number of frames playing per second; the web supports an infinite variety of frame rates.

Artifacts
Small, ugly, rectangular blocks in compressed video caused by bit rates that are set too low.

I-frame
A method of compression where each frame is compressed individually.  Yield excellent image quality, with very large file sizes.  Best format for editing.

GOP (Group of Pictures)
A method of compression where groups of frames are compressed together.  Yields good image quality with very small file sizes. Best for web videos.

What Determines Quality?

  • Image quality is balance of five factors:
    • Codec.  Different codecs require different settings for similar quality.
    • Compressed frame size.  Larger frame sizes require faster bit rates
    • Compress frame rate.  Faster frame rates require faster bit rates.
    • Movement between frames.  More movement between frames requires faster bit rates
    • Bit fate of the compressed file.  Higher bit rates yield higher quality, but much larger file sizes.

Bit Rate Isn't Everything

  • Files encoded at the same bit rate will generally have the same file size, but they may not have the same image quality, unless they also have the same specifications.

Frame Size Makes a Difference

  • Bit rates that work for one format, don't work for others.
  • NTSC DV frame contains 345,600 pixels
  • PAL DV frame contains 414,720 pixels
  • 720p frame contains 921,600 pixels
  • 1080p frame contains 2,073,600 pixels
  • 2K frame contains about 2.21 million pixels
  • 4D frame contains about 8.29 million pixels

Minimize Movement

  • Video compression yields the smallest file sizes when there is very little movement between frames.
    • The more movement between frames in the master file - from camera, transitions, effects, or talent - the higher the bit rate that is needed to properly compress it.
  • If small file sizes are key, minimize on-screen movement; such as hand-held cameras, file noise effects, video noise due to low light, or leaves waving in the background behind your actors.


Friday, 17 January 2014

SQL Server Data Tools Projects Error with the file _Data.sqlinclude


I am having problem to build the project.  The error is:

  • SQL71006: Only one statement is allowed per batch. A batch separator, such as 'GO', might be required between statements.

Solution:

  • Set the Build Action of the file to "None".  It was set to "Build".

More info:

  • Make sure the file (Data\_Data.sqlinclude) is NOT Read Only.
  • Have a Pre-Build event to generate the file with Data\_Data.tt


set doTemplateTransform=
if "$(BuildingInsideVisualStudio)"=="True" set doTemplateTransform=true

if "%doTemplateTransform%"=="true" "$(MSBuildProgramFiles32)\Common Files\microsoft shared\TextTemplating\12.0\TextTransform.exe" "$(ProjectDir)Data\_Data.tt" -a "!!targetDir!$(ProjectDir)Data"

Wednesday, 15 January 2014

Format xml file automatically

Use the free XML Copy Editor

  • Open the file
  • Select "XML" from the top menu and select "Pretty-print" or press <F11>


Saturday, 11 January 2014

Apple loops and sound effects not showing in FCP X 10.1

Trash the FCP X preferences and restart FCP X

Download the free Preference Manager

Delete the preferences manually
  • User > Library > Preferences > com.apple.FinalCut.plist and
  • User > Library > Preferences > com.apple.FinalCut.LSSharedFileList.plist
if you cannot see the Library in the user home folder
  • Open user home folder by <command><shift><H>
  • Click 'View'
  • Select 'Show View Options'
  • Check 'Show Library Folder'
or
  • from Desktop, click "Go" with <Option> key, select Library


Thursday, 19 December 2013

How to ask questions in an interview

uses short, open-ended questions when you want elaboration, and
short, yes-or-no questions when you want to be pointed

e.g. What do you think?

try not to end every question with a series of possible answers

e.g. Do you think x, y, z, q, r or...

The #1 tip for asking better questions? Cut them off at the question mark.

Saturday, 14 December 2013

Split .ape file with .cue file

  • download foobar2000
  • download Monkey's Audio Decoder
  • install the Monkey's Audio Decoder component in foobar2000
  • open the .cue in foobar2000
  • use foobar2000's converter to split the files 
To convert to MP3, download Lame , and copy the files to any folder (e.g. C:\Program Files\Lame) and point foobar2000 to the folder.

Happiness

Happiness is not a destination but a day-by-day journey.

No Sound after upgrade to Windows 8.1 with Sound Blaster X-Fi Xtreme Music

Just reinstall the drive downloaded from Creative.  Drive version is 2.18.15.

Thursday, 12 December 2013

Life

The storms of our life prove the strength of our Anchor.

Friday, 6 December 2013

High Key Photography

A bright, white background creates a high energy, happy, and distraction free scene, perfect for pictures of your friends and family. Known as high key photography, this technique instantly cures problems with ugly backgrounds and focuses the viewer’s attention on your subject.

http://digital-photography-school.com/4-tips-perfect-white-background-high-key-photography

Wednesday, 4 December 2013

Teaching with Video

The whole post...

The 30-Second Summary

  • Know your audience: Learn what your audience struggles with and what they want to know more about and use it to inform your script. Set context around your video by mentioning clear prerequisites.
  • Keep it concise: Cut the fluff from your videos to keep the length manageable, and break down long content into digestible chunks so that viewers can self-navigate.
  • Planning matters: Spec out your video specifically for the online format, and prepare a script before shooting.
  • Quality is essential: You don't have to spend thousands of dollars on equipment, but good audio and a decent lo-fi studio setup with a backdrop can make your production feel much more professional.
  • Look at metrics that tie to your goals: Specific measurements like student projects can speak to the effectiveness of your teaching on an entirely different level than general analytics.
  • Good supplementary content: Supplementary materials, like quizzes, transcripts, ebooks, and PDFs, can be a differentiator for your course and help tailor to different learning styles.
  • Passionate instructors: Put someone who's actually an expert on screen, rather than hiring an actor.

Thursday, 28 November 2013

Darktable

Free Digital Darkroom Software for Mac and Linux

Darktable is a free and open source RAW converter for Apple Mac OS X and Linux users. Its name is formed from it serving the dual features of being a virtual light table for viewing images in bulk and a virtual dark room for processing your RAW files...

Review

Web Site

Lightzone

Free Darkroom Software for Windows, Mac, and Linux

Lightzone is a free RAW converter that is in a similar vein to Adobe Lightroom, though with some distinct differences. As with Lightroom, Lightzone allows you to make non-destructive edits to your photos, so that you can always return to your original image file at any time...

Review

Web Site

Using Table as layout in HTML 5

The HTML5 specification still recommends that you don't use tables for layout, but if you do, you should differentiate those tables from tables that are used for tabular data.

Features to Define Your Table as Layout or Non-Layout

Feature of Table Is a Layout Table?
<table role="presentation"> It probably is a layout table
<table border="0"> It probably is a layout table
<table cellpadding="0"> It probably is a layout table
<table cellspacing="0"> It probably is a layout table
Use of the CAPTION, THEAD, or TH elements It probably is not a layout table
Use of the headers and scope attributes on the TH element It probably is not a layout table
<table border=""> It probably is not a layout table
<table border="1"> It probably is not a layout table
Visible borders set with CSS It probably is not a layout table

Thursday, 14 November 2013

Study Your Children

The greatest gift you can give your child is not your riches, but revealing to them their own!
- Max Lucado

Friday, 18 October 2013

Windows 7 - missing LPK.dll

Issues:
  • having this error when I tried to open FireFox, IE and some other applications

Solutions:
  • in Save Mode
  • Open cmd "Run as Administrator"
  • enter "sfc /scannow"

Tuesday, 3 September 2013

Deliverance

We see Satan’s tricks and ploys, but God sees Satan tripped and foiled.

Monday, 24 June 2013

Snowflakes

Snowflakes are frail, but if enough of them stick together they can stop traffic.

Dell Inspiron N5040 Brightness Control not working with TeamViewer

Pressing the <Fn> and <F?> keys can only move up and down two levels and the screen is extremely dim...
  • Go to the Device Manager, open Monitors, 
  • right click on PnP-Monitor (Standard)
    • select Properties and check if the Manufacturer is "TeamViewer GmbH"
  • Uninstall this driver if it is the case and the system should restore the default monitor driver


Thursday, 13 June 2013

Loss

A man once went to a minister for counseling.

“I’ve lost everything” he bemoaned.
“Oh,” the preacher responded, “I’m so sorry to hear you’ve lost your faith.”
“No,” the man corrected him, “I haven’t lost my faith.”
“Well then,” replied the preacher, “I’m sad to hear you’ve lost your character.”
“I didn’t say that,” the man corrected.  “I still have my character.”
“Then I’m so sorry to hear you’ve lost your salvation.”
“That’s not what I said!” the man objected, beginning to lose patience.
The minister explained, “Well, you have your faith, your character, and your salvation.  Seems to me, you have lost none of the things that really matter.”

Wednesday, 12 June 2013

Friday, 17 May 2013

Delete hiberfil.sys in Windows 7

Control Panel
Power Options
Change plan settings (the selected Preferred plans)
Change advanced power settings
Allow hybrid sleep - Off

Run cmd as Administrator
Type "powercfg -h off"

The link provide detail info.

Tuesday, 14 May 2013

Detach a Process in Visual Studio and IE 10 javascript debug

Having an error after installing IE 10:
Attaching the Script debugger to process '[<ID>]' iexplore.exe' on machine '<computer name>' failed.  A debugger is already attached.

To detach this process:
  • Open the Processes windows (Debug, Windows, Processes)
  • Select the process (iexplore.exe with that ID), right click and select "Detach Process"

To fix the problem without detaching the process every time:
  • run the following in a command window: regsvr32.exe "%ProgramFiles(x86)%\Common Files\Microsoft Shared\VS7Debug\msdbg2.dll"
  • make sure run the cmd prompt as an administrator


FireFox Bad Request Error

Here is the link showing how to fix this problem:
http://timourrashed.com/how-to-fix-the-400-bad-request-error-message-from-a-website/

Wednesday, 8 May 2013

FireFox 18.0.1 stops working

First posted on Feb 2, 2013
I am not able to start FireFox after installing the latest version of Nvidia driver.  I can start in safe mode.  It is strange that I can start the winPenPack version of the X-FireFox (18.0.1).

I have tried to disalbe all the add-ons and plugins, this didn't work.

Solution
After I do a "clean" installation of an older version (301.42) of the video driver, finally, I can start FireFox again.

Update:
I forgot this problem and upgrade to 314.22, the problem is back...

New Solution
In safe mode, go to  Options, Advanced, General and uncheck the "Use hardware acceleration when possible."

Tuesday, 30 April 2013

Visual SourceSafe - show all checked out files


  • Go to View, Search, Status Search... (<Ctrl> S)
  • Select either all or a specific user
  • Select "Search Area" options (the first option is useless, select either second or third options)


Thursday, 21 March 2013

Install NuGet package manually

I accidentally (without checking the description) installed a new version of a package which is not compatible to the project and I cannot find the correct version from the NuGet Installer anymore.  I have a test project which contain the package.  Since I cannot install the package from the UI, I need to install it manually.

Open the Pack Manager Console (View, Other Windows) and type the following:
  • Install-Package <package name> -Source C:\Projects\<project name>\packages\
The package name will be the first part of the folder name before the version number.  For example, the package folder name is "MvcMailer.4.0" and the package name is "MvcMailer".

Web Application targets IE 9 and above...

Add this to the master page or the shard layout file, and IE will not go into the compatibility mode (IE 8)
  • <meta http-equiv="X-UA-Compatible" content="IE=9" />

A helping hand

"Do all the good you can, by all the means you can, in all the ways you can, in all the places you can, at all the times you can, to all the people you can, as long as you ever can."

John Wesley

Monday, 18 March 2013

Android download won't go away

Issue:
  • I have the Facebook download for a few days and even I uninstalled Facebook it won't go away.
Solution:
  • Go to Application and find Downloads
  • Click "Other Downloads", select the item, and click "Cancel"




Keurig problem - water flow back into reservoir

Press the hole and not stopping the water to come out. The water is not hot, check it, just in case.

Planning

If you fail to plan, you're planning to fail.

Friday, 15 March 2013

LINQ Zip and join

Add two list sequentially together according to it order... stop when end of one list.

Fast but limited compare with join.

(roleList).Zip(roleDescriptionList, (r, rd) => new RoleDescription() { roleID = r.dataID, role = r.dataValue, description = rd.dataValue }).ToList();

roleList and roleDescriptionList are two separate lists.  They can be unrelated at all.
Using Zip() to join them together to create a new list of object "RoleDescription" one by one.

To have better control, you should use join instead.


IList<RoleDescription> result = (from r in roleList
                         join rd in roleDescriptionList
                         on r.dataID equals rd.dataID
                         select new RoleDescription { 
                             roleID = r.dataID, 
                             role = r.dataValue, 
                             description = rd.dataValue }).ToList();

Wednesday, 13 March 2013

MVC Partial View

When having <script></script> in a partial view, remember don't use the @section Scripts {
} since the partial view has no Layout (i.e. you have this @{ Layout = null} on the top of the partial view.

Friday, 8 March 2013

Idempotent

Calling the function a million times has the same effect as one request.

Example:
WebAPI Uniform Interface:
  • GET, PUT and DELETE

Wednesday, 20 February 2013

MVC StringLength and maxlength

When you add the validation StringLength in MVC, it won't automatically limit the user to the max length.  You need to manually to add this in the View.

You cannot use @Html.EditorFor and you should use @Html.TextBoxFor.


<%=Html.TextBox("polNum",null, new {maxlength=10}) %>

@Html.TextBoxFor(model => model.homePostalCode, new { maxlength = 7 })

Wednesday, 13 February 2013

MVC Razor Html.ActionLink new page

@Html.ActionLink("More info...", "../newpage", null, new { target = "_blank" })

Cannot put the target option in the 3rd parameter, it will treat it as "?target=_blank".

Tuesday, 12 February 2013

jQuery UI Dailog, IE and DropDownList

There is a problem to select from a dropdownlist in a jQuery Dialog plug-in.  It happens only in IE (8 and 9, at least).  It works in FireFox.

  • The very first time (after opening the dialog) will work but it won't when I try to select another value
  • I can select the value using the keyboard
  • Tab to the dropdownlist and select with the mouse
  • I tired to add the z-index to the dropdownlist but it doesn't help
Solution:
  • The current solution is adding a mouseover event to set the focus to the dropdownlist.
onmouseover = "this.focus();return true;"


Relationship

“I’d rather do nothing with you than something without you.”

Monday, 11 February 2013

Relationship

Relationships don’t survive because the guilty are punished but because the innocent are merciful!

Tuesday, 5 February 2013

jQuery Template

pass a string:
$.tmpl("<div class="myClass">${FirstName},/div>", myObject).appendTo("#myDiv");

use a selector to find a script block on the page:
$("#myTemplate").tmpl(myObjects).appendTo("#myDiv");

...

<script id="myTemplate" type="text/x-jquery-tmpl">
    <tr>
        <td>${FirstName},/td>
        <td>${LastName},/td>
        <td>${Twitter},/td>
    </tr>
</script>

get an external "html" which contain the html template:

$.get("MyTemplate.htm", function (data) {
    $.tmpl(data, myObjects).appendTo("#myDiv");
});

jQuery General Performance Tips


  • use the latest jQuery
  • Caching Selections (assign it to a variable) 
  • Caching Other Items
  • Use element properties (DOM) when possible (instead of jQuery properties)


Monday, 4 February 2013

jQuery Type Testing Functions

  • Determine the type of an object
  • Useful for optional parameters & validation

Functions:
  • $.isArray(array)
  • $.isFunction(function) - another way to do this ( if (typeof <functionName> == "function")
  • $.isEmptyObject(object)
  • $.isPlainObject(object)
  • $.isXmlDoc(doc)
  • $.isNumeric(number)
  • $.isWindow(window)
  • $.type(object)

 Return Values:
  • boolean
  • number
  • string
  • function
  • array
  • date
  • regexp
  • object
  • undefined
  • null

Turn javascript object into a string

use json2.js from http://www.JSON.org/json2.js

e.g.
<script src="json2.js"></script>
...
JSON.stringify( {
    FirstName: $('#FirstName').val(),
    LastName: $('#LastName').val()
});

To turn a JSON string into javascript ojbect, use parseJSON.

var json = '{"fname" : "john", "lname" : "smith", "age" : 35}';
var jsObject = $.parseJSON(json);


Fiddler

Download the free web debug tool here:
https://fiddler2.com/fiddler2/version.asp

When working on the localhost, add the "." before the port, e.g.

http://localhost.:1064/

WCF returning Json data

in the .net world, we need to get the data by getting the property d like this:

var cust = data.d[0];

var cust = data.d.firstname;

this won't work: var cust = data[0];

Thursday, 31 January 2013

.Net Resource file - multiple designers.cs files

Open the .csproj file
find the "LastGenOutput" tag for each resource file and make sure it is <resource file name>.Designer.cs


MVC - Sending Email using Exchange Server

Add the following in the Web.config file:

<system.net>
  <mailSettings>

    <smtp from="info@mycompany.com">
<network enableSsl="false" port="25" host="mail.mycompany.com" defaultCredentials="true" />
    </smtp>


  </mailSettings>


</system.net>

Without setting "defaultCredentials" to true, you can only send email in the same domain.  When you send email outside the domain, you will receive "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for whoever@notmycompany.com" error.

Monday, 28 January 2013

Tough person around you...

You can’t change a person, but you can change the way you see him/her.

You may not change the person, but it’ll change your attitude toward him/her.  Who knows? Maybe he/she’ll start to change when you start to see him/her differently!

Friday, 25 January 2013

Bible

Yes, any Bible verse can be misused, but that doesn’t make it useless!

MVC Validation - Integer types

All the fields with Integer types will be required by default unless we declare it as <Nullable>.

Thursday, 3 January 2013

C# HashSet

A HashSet holds a set of objects, in a way that it allows you to easily and quickly determine whether an object is already in the set or not.

C# HashSet class preserves the order of the elements.

The only catch of HashSet is that there is no access by indices.

Saturday, 22 December 2012

Add Tag with folder and file names

TagScanner

Go to tab "TAG Processor" and select "Generate TAG from filename" from the Action group (2nd icon) on the tool bar

e.g. \%album%\%disc% <%title%->\%track%-%title%
  • You can use the file and folder names
  • You can combine tag fields like I put %title% twice here, TagScanner will just concatenate them together
  • You can add text to the field (<%tag filed%> like what I have done <%title-%> to add a "-" after the first part of the %title so that my title tag will be part of the folder name and a "-" and part of the file name
  • You can preview the result before you generate the tags



Mp3tag

After select the folder(s) / file(s), select the file(s), right click and select Convert, Filename -Tag

but it is very slow...

Friday, 21 December 2012

Ubiquitous Language

A core principle of domain-driven design is to use a language based on the model.

Wednesday, 19 December 2012

Create a DDD Solution


Starting a New Solution

  • Create a Blank Solution
  • Add a Core Class Library Project
  • Add an Infrastructure Class Library Project
  • Add your UI project (Console, WinForms, WPF, ASP.NET MVC)
  • Add references to Core from Infrastructure and UI 
  • Add a reference to Infrastructure from UI

  • Add a Controller, View
  • Add an Interface <IMyInterface> (new folder "Interfaces" in Core) with a method
  • Implement the Interface in Infrastructure (in a class <MyInterface>) with the method
  • In the controller:
  • Add the private field of the <IMyInterface>
  • Add the constructor with <IMyInterface> as parameter
  • Add the constrcutor without parameter to add the parameter
  • In the control, call the method and show the result to the view



Onion Architecture Principles

All code depends on layers closer to center (Domain Model)
Inner layers define interfaces; outer layers implement these interfaces
Layered behavior around the Domain Model
Infrastructure and UI concerns pushed to edge
  • Depend on Application Core, not vice versa



Dependency Inversion Principle (DIP)

High-level modules should not depend on low-level modules.  Both should depend on abstractions.
Abstractions should not depend on details.  Details should depend on abstractions.

Domain-Centric Design / Domain Driven Design

The problem-space of your application is its domain.  If you are going to write a banking software system, you need to have a good understanding of what banking is all about, you must understand the domain of banking.

A domain is something of this world and we need to create an abstraction (a blueprint) of the domain to transform the domain into software constructs.  The abstraction is a model, our internal representation of the target domain.

The model is the common ground, the place where the software meets the domain.

The objects you design to model the domain are domain objects (model objects / model).
  • Encapsulate application business logic and rules
  • Maintain any state required to do so
  • Do not depend on external infrastructure concers


Page Inspector in ASP.NET MVC

Page Inspector in Visual Studio 2012 is a web development tool with an integrated browser and browser tools. Select any element in the integrated browser, and the Inspect feature instantly highlights the element's source and CSS. You can browse any MVC view, quickly find the sources of rendered markup, and use browser tools right within the Visual Studio environment.

It is something like the FireBug add-on in FireFox.

Friday, 7 December 2012

Installing SQL Server 2012 Express

Problem:
Cannot find the vc_red.msi file in <temp folder>\redist\visualstudioshell\VC10SP1
  • The file is in the x86 folder insider VC10SP1.  But even I copied the content in x86 to VX10SP1, it is still not work.
  • Try to manually uncompressed the package
  • Run as administrator
Solution:

  • Make sure to download the right version of the setup file.  Download 64-bit version for 64-bit OS.


Wednesday, 5 December 2012

C# "??" Operator

The "??" operator is called the null-coalescing operator and is used to define a default value for a null able value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.

objNullable = objNullable ?? new objMyObject();

Tuesday, 20 November 2012

Share Mouse and Keyboard with computers (software)

The following software are working with me between my Windows 7 and OS X:
  • Synergy http://synergy-foss.org/
  • ShareMouse http://www.share-mouse.com/



Wednesday, 7 November 2012

Crop / Rotate images in Batch using IrfanView

After scanning a book, I need to crop (all images, the same way) and rotate (half of the images) the images.

Open IrfanView with one of the image, try to crop it correctly, save it and get the width and height (and the X and Y offsets, if needed) of the final image.

In IrfanView
  • File, Batch Conversion/Rename...
  • Select "Batch conversion" or "Batch conversion - Rename result files" accordingly
  • Check "Use advanced options (for bulk resize...)
  • Click "Advanced" button
  • A popup window (Set for all images:) appears
Cropping the images
It depends on how you scanned, you should crop all images first.  In my case, all the image can be cropped the same way, therefore, if I rotate the images first, I may need to crop the rotated images differently
  • Uncheck any options that are not applicable
  • Check "CROP"
  • Enter the Width and Height (from the above)
  • Enter the X-pos and Y-pos, if necessary
  • Click "OK"
continue with "Common Steps"
Rotating the images
  • Uncheck "CROP" and any other options that are not applicable
  • Check "Fine rotation"
  • Enter "180" (i.e. to rotate left/right twice)
  • Click "OK"
continue with "Common Steps"
Common Steps
  • Select the files from the top right windows, click the "Add" or "Add all" button.  Be careful if the order of the images is important (if you rename the file), the last selected file is always on the top.  You will need to change it in the "File name" text box or move it in the "Input files" window
  • Change the "Name pattern" (if you want to rename the file and in a specific way)
  • Enter the "Output directory for result files"
  • Click "Start Batch"



Thursday, 18 October 2012

Turn Off Ad Tracking on iOS 6 (iPhone, iPad)

Apple sets IFA / IDFA (identifier for advertisers) on by default:
  • Go to Settings, General, About, Advertising, Limit Ad Tracking : ON





Friday, 7 September 2012

PayPal - Preferred Payment Method

There are times when you cannot change the account when making payment by PayPal.  Payments will be made with your default payment method unless you select a preferred payment method.

After making the payment, login to PayPal, click on "Profile" (ignore the drop down menu), click "My money" on the left, click "update" in the "My preapproved payments" section.

You will see the transaction there and click on the "Merchant" link of the transaction, click "Change" of the "Backup Funding Source" in "Funding Source" to select your preferred payment method.

Tuesday, 4 September 2012

Shallow Copy and Deep Copy


Shallow copy versus deep copy is only meaningful with "reference types" and not with "value types".

Shallow Copy
http://0.tqn.com/d/visualbasic/1/0/4/a/dsgnshlwdeepcopy-1.gif
Deep Copy
http://0.tqn.com/d/visualbasic/1/0/6/a/dsgnshlwdeepcopy-Dup.gif


Wednesday, 29 August 2012

Eyes that chose to see the unseen

“I believe in the sun, even though it doesn’t shine.
I believe in love, even when it isn’t shown.
I believe in God, even when he doesn’t speak.”

Monday, 20 August 2012

Play back video in different speed on iPad - Touch The Video

The app is pretty good and it is on sales now for only US$ 0.99.

It has a lot of other features too...

Sunday, 19 August 2012

DVD / CD Code 39 Error, Lost CD/DVD drive

If uninstalling and re-installing the driver don't fix the problem.  Try to delete the LowerFilters and / or UpperFilters registry values.

  • Run "Regedit" and go to the following Registry Key
  • go to the following HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\4D36E965-E325-11CE-BFC1-08002BE10318
  • Delete all the LowerFilters and UpperFilters



Wednesday, 15 August 2012

Debug Javascript in FireFox with Firebug


  • Go to the web page you would like to debug
  • Open Firebug from Tools, Web Developer, Firebug, Open Firebug
  • Click the "Script" tab
  • Click the Reload link
  • Set the breakpoints...



Tuesday, 14 August 2012

Headphones

Open Back headphones
They are designed to give you a more speaker-like experience, ideal for studio monitoring or for simply listening to tracks. They allow for some of the sound to leak and some ambient noise to seep in, creating an illusion of distance from the sound source.

Closed Back headphones
Closed Back headphones on the other hand have closed "cans" that operate quietly and block out ambient noise. They are ideal for recording because they prevent 'spill' from the headphones through microphones into the current track you're recording, but may not have as much soundscape as Open Back ones.

DJ headphones

DJ headphones are workhorse headphones that are tuned for bass and treble response as well as providing good isolation. They generally have features like swivel earpiece for one ear listening, and a convenient folding structure for portability.

Monday, 13 August 2012

Friday, 3 August 2012

HSL

Hue adjusts the actual colors of the image.  We can adjust how individual colors behave.  This is extremely useful in landscape work, where you can fine-tune the color of greens and blues, for instance, without affecting browns or oranges. This is great for altering foliage and sky, without adjusting sticks, dirt, etc. It also works well if you have a human subject in your landscape: you end up with nice bright foliage and a nice deep blue sky, but your subject can still have nice, normal, subtle and subdued skin tones.

Saturation slider is a huge help when you want to boost a certain colour over another: I often boost blues and greens on landscapes and sometimes bring yellows, oranges, or reds down in portraits to ease skin tones.

Luminosity is something a drastic.  It's minor, but it's there, and it's one of those little touches that will really seal the deal.

The big thing with the HSL Sliders is to try them and experiment: In many cases, you never know what will look good or not unless you just go ahead and try, and dont be afraid to get drastic.

Lens Flare

Lens Flare is caused by strong rays of light directly hitting your lens and causing a slight sun burst.