Friday, June 6, 2014

Folder-like html nested lists & Create your own CSS Icon Font

Recent trend saw the rise of mobile technology. In order to accommodate it, websites have to cater mobile users as well. Bootstrap, the most popular front-end framework for developing responsive, has take to web development to a more elegant way. At the same time, Icon Font has rode along the wave. Two major popular clans of Icon Font is Glyphicons & Font Awesome. Icon Font comes with a lots of benefits, eg, size, color, shape. Why it has such advantages? Reads more.

I involved in a website, where one of the requirement is to create Folder-like html nested lists. There's some trick to do it, some have introduced at:
1) using image (simple)

2) CSS background property (a bit imagination requires)

So far no issue, but to apply them on HTML with bootstrap, it really takes a bit extra of time, especially for those people that are not good in CSS, like me. I was looking fast-and-clean approach, something like CSS Icon Fonts, but built-in Glyphicons & Font Awesome does not come with it, Goggling other existing icon font also yields no result.

Then I bumped into this website, fontastic, prompting the idea of creating my Icon Font. From here, I found out that it needs .svg file to create icon font. SVG defines graphics in XML format. Now you know why Icon Font can be sized, since it's vector image. Thus I pick-up the tool, svg-edit, I used before in this post, and start creating the asset. Let's begin.

1) Download the "svg-edit", extract the zip file and click "svg-editor.html" to load the editor.
2) You'll be welcomed with default blank canvas. Click on the "Rectangle".


3) Try to create something like this. As you can see, I create the vertical rectangle over the size of the canvas. If i create with exact fit, it'd be far too small when Icon Font generated later, could be padding or margin issue. Try it yourself. And I found out that the color does not matter now.


4) When you done, save the file, let's say "m.svg". You can click on the "SVG", and reveal the svg content.



5) Now the asset is done. Let's go to create the Icon Font at fontastic.
6) Select "Modify Font" if it default to it, else create new font.



7) Give a descriptive name, this will be the name use in html.


8) Now we import the "m.svg" created early.


9) Import successful!


10) Preview of our Icon Font. It still looks weird, huh? Bear for while, click "Change set name".

 11) Change the set name



12) Click this set to add to your font, and you can see you have "1" ready to publish.


13) Click "Publish" tab and click the "Manual Download" button.


14) Now you can prepare to add it to your HTML. Let's use one of the very nice bootstrap menu library, metisMenu.

15) Download it's js library and sample. Add these few lines into the sample html provided by metisMenu.

  

This CSS is for adding extra second-level indentation.


Add this HTML to all the nested list "li" , and it is for adding the Icon Font generated.
  

16) Yeah, a nice folder-like html nested lists you got by now! You can download the source here.


p/s: When you use this Icon Font in Google Chrome browser, you might experience some weird issue. I think Google Chrome use some scaling technique to adjust the web content, so when you enlarge the browser to a special size like "110%", it skewed.


So, you have to apply the fix, for more please follow this link.
@media screen and (-webkit-min-device-pixel-ratio:0) {
 @font-face {
 font-family: 'startcoding';
 src: url("fonts/startcoding.svg#startcoding") format("svg");
 }
}

Wednesday, June 4, 2014

"HTTP Error 401.3 - Unauthorized" on a unity web player page?

Recently, i involved in a project that has to rush to deploy. Since I work in mobile game company, some games have to be able to run in web browser as well. Unity web player usually would be generated by Unity along with a html page, my task was just to link to that page. So, I uploaded the zipped game content using FileZilla to the Azure server.

To host in IIS 7.5, and allow ".unity3d" to be downloaded is not an issue, what you need to add is new MIME, as explain here.

    
        
           
        
    


Easy, huh? I thought so. Then I browse to my page.
Kaboom!

HTTP Error 401.3 - Unauthorized

You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.



I just did what's considered normal process, right? As rushing for live, I was cracking my head and wonder what went wrong. Goggling on internet gave me no result which could link error 401.3 with Unity web player. After few hours of trial-and-error, 2 workarounds came into my mind:

1) Permissions and user rights : I have tried to give full-rights on the folder, but failed.
2) Thinking to write code on Asp.net Impersonation, but it invites security concerns.

Suddenly, I found something special:



Hey, why the file name is in green color?
And another googling on this, I found out that:
Green means encrypted, blue means compressed in Windows.

The resolution is:
1) Right-click the file, click "Properties"


2) Click the "Advanced.." button.


3) On the "Compress or Encrypt attributes" section, un-check the "Encrypt contents to secure data"


After the decryption, the text becomes normal black color.


And refresh the browser again, it's ok.


I found out that:
1) when i uploaded the zipped content thru' FileZilla, then this encryption will happen. It must be caused by the FTP issue.
2) when i uploaded the extracted content thru' FileZilla, no issue.


Tuesday, April 15, 2014

Private domain SSL setup on Winodws Azure VM

Nine years of programming life, and finally I got the chance to setup the domain & SSL on my own. Usually I work in enterprises, this will be done by MIS guy and programmer will be shut-off from production environment. With the new job and as a new back-end department pioneer, here comes the opportunities.

For the first few steps, I'll show more on hosting with Windows Azure, if any other hosting company, the steps will be roughly the same.

1) Hosting with Windows Azure: You have to purchase a cloud server. My case I use: http://azure.microsoft.com/en-us/. You can start with trial plan but it will not last long, at most few days only. Here're the few links you can start with:


It's highly recommended that you use new IE (I use IE9) for accessing Windows Azure, even for service payment. Most of the standard browsers do not work well with IE-only Windows Azure.

2) Hosting with Windows Azure: Your web binary files can be deployed through FTP, and this is the steps: http://www.intstrings.com/ramivemula/articles/enable-ftp-access-on-windows-azure-vm/

3) Hosting with Windows Azure: Remember to open the Azure HTTPS endpoints (usually is port 443) of the server:


4) Domain with GoDaddy: For hosting with Azure server, you'll get a sub-domain that looks like this: xxx.cloudapp.net. But for a HTTPS to be worked, you need your own private domain. No choice but have to buy one. My company bought one at: http://my.godaddy.com/. Mind you, there's no such thing called customer service in GoDaddy, everything is on your own. When you get the domain, go to: https://mya.godaddy.com/default.aspx?prog_id=GoDaddy&.


Click on the "Launch" near the domain and you will see the domain you purchased.


5) Domain with GoDaddy: For hooking up the domain and the Windows Azure server, some details is on here: http://blog.smarx.com/posts/custom-domain-names-in-windows-azure. The latest GoDaddy site might looks like this. Click on the "Manage" near the "Forwarding".


Add one entry of your domain here.



Click on the "DNS Zone". Change the Host,"@" to Windows Azure Virtual IP & CName,"www" to Azure DNS name. You can get this from Windows Azure Dashboard.





6) Domain & Hosting: After the TTL period, you can go to the website through the domain. You will get the standard IIS welcome page that looks like this:


7) Domain & Hosting: You have to go back to Azure IIS and add this domain to the website. Click "Add Web Site".


On the new website added, click "Bindings" and key-in the domain info.

And your website should be browsable by now.


8) SSL with GoDaddy: Now we come to final part, which is SSL. Purchase the SSL from GoDaddy. Create the certificate by following this link: http://azure.codegrains.com/2013/07/step-by-step-guide-for-implementing.html (until step 8). It takes only few minutes for SSL to be signed.


Install the SSL certificate by following this link: [To Install an SSL Certificate in Microsoft IIS 7] http://support.godaddy.com/help/article/4801/installing-an-ssl-certificate-in-microsoft-iis-7?locale=en&countrysite=my&pc_split_value=4

9) SSL: Do not forget the HTTPS binding in the new website.


And your site should be browsable through HTTPS by now.


10) SSL: After the SSL is setup, you can check your SSL security level on your server. Here're the few websites that you can check:

  1. https://sslcheck.casecurity.org/en_US (you might need to clear your cache after your first run)
  2. https://www.ssllabs.com/ssltest/analyze.html
  3. http://foundeo.com/products/iis-weak-ssl-ciphers/test.cfm

11) SSL: With default settings on Windows Server 2008 R2, most probably you'll be getting an "F".


it's because of SSL version 2 is not disabled on server. Here're the links that you can refer to.
  1. http://support.microsoft.com/kb/187498
  2. http://hosting.com/support/pci-security-scan/disable-sslv2-for-microsoft-iis7-under-windows-server-2008-64bit/
  3. http://blogs.msdn.com/b/httpcontext/archive/2012/02/17/how-to-disable-ssl-2-0-on-windows-server-2008-r2.aspx
12) SSL: After adding new entries on registry and restart the server, I got this, a "B".


13) Done! Phew, what a long way.

Thursday, January 2, 2014

Developing a FPS game with Unity3D

Almost after 10-year ago I developed some basic stuffs on OpenGL, I manage to regain some interests on developing a FPS (First-person shooter) game again. I have to admit I am not an avid-gamer, and just a casual gamer, but it's kinda fun to work on it.

There're couples of top-notch free 3D game engines in the markets, ie:
  1. Unity
  2. CryEngine
  3. Unreal Development Kit (UDK)
and many more. By starting with the game engine, you focus your work on game itself, and not the engine.

After some tries-and-errors, I chose to start with Unity. Its UI looks simple and the requirement on hardware spec is low, if compare with CryEngine & UDK. The ability to export to multiple platforms, likes Apple's iOS & Google's Android, is also another reason I choose it.


For those FPS lover, I highly-recommend to try the Unity3D with this book: "Beginning 3D Game Development with Unity 4", by Sue Blackman.


Not only it guides you with some basic concept, it also comes with chapters on building a FPS game on one of the level from scratch. And for the past few months, I was following all the chapters closely and it's quite fun.

Here are some of the screenshots from the sample of the book (credit to the author)




Impressive with the graphics, huh? Why waits then? :)

You can reach the author here, and sometimes she is at Unity forum as well.
You can read some free excerption from Google Books too.

Two things bear in mind:
  • Unity is getting updated frequently, some of the old features might not available (or even works, a.k.a bugs) in new version. To follow the chapters in this book, please download a suitable version 4.2.X from here.
  • There're couple of erratas in the book, my suggestion is: please open the finished chapter along with you own project, side-by-side, to compare whenever something's wrong.

Tuesday, November 12, 2013

Access Denied: XXX needs the following permission(s) to perform this action: View collection-level information

Due to some mis-understanding, my windows account in server that hosts TFS 2010 was deleted, thru 'Computer Management->System Tools->Local Users & Groups'. Then I found I got problem to log-in.


After I added my account back, I encountered this error message when connect to VS2010:

Access Denied: 'XXX\gan' needs the following permission(s) to perform this action: View collection-level information.


At the TFS server, I launched the "Team Foundation Server Administration Console", I found my windows account is still there. I know my account is not associated with TFS properly anymore.


From MSDN: Team Foundation Server Permissions, it got something to do with 'Project-Level Permissions':

Permission Name
Name at Command Line
Description
Create test runs
PUBLISH_TEST_RESULTS
Users who have this permission can add and remove test results and add or modify test runs for the team project.
Delete team project
DELETE
Users who have this permission can delete the project for which they have this permission from Team Foundation Server.
Delete test runs
DELETE_TEST_RESULTS
Users who have this permission can delete a scheduled test for this team project.
Edit project-level information
GENERIC_WRITE
Users who have this permission can edit project-level permissions for users and groups on Team Foundation Server.
Manage test configurations
MANAGE_TEST_CONFIGURATIONS
Users who have this permission can create and delete test configurations for this team project.
Manage test environments
MANAGE_TEST_ENVIRONMENTS
Users who have this permission can create and delete test environments for this team project.
View project-level information
GENERIC_READ
Users who have this permission can view project-level group membership and the permissions of those project users.
View test runs
VIEW_TEST_RESULTS
Users who have this permission can view test plans in this node.


Browsing from 'Source Control Explorer', I really got no idea whether is my account still there. Can you tell??



No choice, I have to remove and re-add. After adding my windows account in the "Team Foundation Server Administration Console->Administration Console Users-Add", no error logged but my windows account is not there.


I opened the log, and found there's an error.
[Info   @01:36:05.790] -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
[Info   @01:36:05.790] Running Readiness Checks ...

[Info   @01:36:05.790] -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

[Info   @01:36:05.791] 

[Info   @01:36:05.791] -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

[Info   @01:36:05.791] Activity.Verify

[Info   @01:36:05.792] -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

[Info   @01:36:05.797] Verify: AccountsChecks(VCONTAINER): Starting Verification

[Info   @01:36:05.797] A generic container node that does not contribute to results

[Info   @01:36:05.797] "Verify: AccountsChecks(VCONTAINER): Exiting Verification with state Ignore and result Ignore"

[Info   @01:36:05.798] Verify: AccountsChecks\Verify Accounts Feature(VCHANGEFEATURE): Starting Verification
[Info   @01:36:05.798] Verifies a condition
[Info   @01:36:05.798] "Verify: AccountsChecks\Verify Accounts Feature(VCHANGEFEATURE): Exiting Verification with state Completed and result Success"

[Info   @01:36:05.798] Verify: AccountsChecks\Verify Accounts Account(VACCOUNTVALID): Starting Verification

[Info   @01:36:05.798] Verifies the account is a valid account

[Info   @01:36:05.799] "Verify: AccountsChecks\Verify Accounts Account(VACCOUNTVALID): Exiting Verification with state Completed and result Success"

[Info   @01:36:05.799] Verify: AccountsChecks\SqlLogin(VSQLLOGIN): Starting Verification

[Info   @01:36:05.799] Verifies the given account does not already have a SQL login that is denied access or with the wrong SID

[Info   @01:36:05.801] Verifying SQL login of account XXX\gan does not exist on XXX\SqlExpress, or if it exists, it does not have a different SID and it is not denied access to the server.

[Error  @01:36:05.805] The login for the given account has the wrong SID.

[Error  @01:36:05.805] !Verify Error!: TF255441: An orphaned SQL Server login is associated with the following account: XXX\gan. The login has an incorrect security identifier (SID). The server selected to host the databases for Team Foundation Server is: XXX SqlExpress. You must delete the login from the SQL Server instance on that server.

[Info   @01:36:05.805] "Verify: AccountsChecks\SqlLogin(VSQLLOGIN): Exiting Verification with state Completed and result Error"

[Info   @01:36:05.805] Verify: AccountsChecks\DBExists(VDBEXISTS): Starting Verification

[Info   @01:36:05.805] Sql Database Existance Verification

[Info   @01:36:05.809] "Verify: AccountsChecks\DBExists(VDBEXISTS): Exiting Verification with state Completed and result Success"

[Info   @01:36:05.809] !Verify Result!: 4 Completed, 0 Skipped: 3 Success, 1 Errors, 0 Warning
Looks like TFS only cater an account when it does not exist, but it cannot re-create the account due to security issue.

So, I have to go to MSSQL-Express and remove my windows account.


You can check the DB used in 'Data Tier Summary' at "Team Foundation Server Administration Console" (more info at 'Team Foundation Server Databases'):


After adding my windows account again in the "Team Foundation Server Administration Console->Administration Console Users-Add", everything is ok!
[Info   @01:51:33.399] -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
[Info   @01:51:33.399] Adding account to collection databases ...

[Info   @01:51:33.399] -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

[Info   @01:51:33.400] Getting collections...
[Info   @01:51:33.401] Changing collection: DefaultCollection
[Info   @01:51:33.403] ConnectionString: Data Source=XXX\SqlExpress;Initial Catalog=Tfs_DefaultCollection;Integrated Security=True

[Info   @01:51:33.405] ModifyExecRole: Add:XXX\gan

[Info   @01:51:34.498] result: Success

[Info   @01:51:34.499] Added XXX\gan to Tfs_DefaultCollection (XXX\SqlExpress)

[Info   @01:51:34.499] Changing collection: YYY

[Info   @01:51:34.502] ConnectionString: Data Source=XXX\SqlExpress;Initial Catalog=Tfs_YYY;Integrated Security=True

[Info   @01:51:34.503] ModifyExecRole: Add:XXX\gan

[Info   @01:51:35.381] result: Success

[Info   @01:51:35.381] Added XXX\gan to Tfs_YYY (XXX\SqlExpress)

[Info   @01:51:35.388] ADDCOLLACCOUNT Completed.

[Info   @01:51:35.389] Starting Node: ADDSYSTEMDBACCOUNT

[Info   @01:51:35.389] Add account to system dbs

Done. (You might need to re-map your work-space after this)