Using CSS Properties to Create a Cool Button

20-10-2014

Using CSS properties alone, recreate this button:

enter image description here

This would be a great test of the candidate’s CSS3 skills. This button is loaded with that kind of stuff. Things I would look for:

  • How did they handle multiple borders? box-shadow is probably the best way here.
  • Did they use text-transform: uppercase; for the text? That would be best.
  • How did they handle the stars? Pseudo elements would be a good candidate there. Did they use unicode? Icon font?
  • Did they catch the subtle text-shadow?
  • How did they split the background in the main part of the button? a linear-gradient with no fade would be a good technique there. Or box-shadow.
  • Were they careful with the nested border-radius?

My solution

a {
  border-radius: 4px;
  border-color : aliceblue;
  background-color: gray;
  padding: 5px;  
  display:inline;
  text-decoration: none;
  text-transform:uppercase;
  box-shadow:0px 0px 1px 4px red,
    0px 0px 1px 8px #000000;
  text-shadow:1px 1px #00ffff;
  font-weight: bold;
  background: linear-gradient(180deg, lightgray, gray);
}

a:before, a:after{
  content:'\2605';
}

The challenge/question was from here

Written with StackEdit.

Read More »

Investigate High CPU usage or Infinite Loop via WinDbg

12-10-2014

Confirm the Issue

We can investigate it using TaskMgr, if the CPU is around 25%, 50% or 100% (depends on how many cores you have, e.g. for 4 cores, 25% mean the program used up 1 core.)

If the CPU rate is not high but the program hangs, it probably indicates a deadlock.

Find the Thread

Note: WinDbg will suspend all thread, so we need to run the g command frequently if the program has something needs to run continuously, for example the program may disconnect from the server if suspended too long.

Preparation

Open WinDbg and the Command window(alt+1)

  • Attach to the process that you want to inspect using File-->Attach to a process(F6). And run g` in Command window immediately.
  • See the instructions here to setup the Symbol File Path and don’t forget to tick the reload check box. If you process cannot be suspended to long, then I would suggest just include the minimal necessary symbol files, especially you should exclude the Microsoft Symbol Server.

Read More »

Modular Design Patterns in JavaScript

05-10-2014

In this article, I’ll be describing the structure and benefits of an extended modular design patterns, that includes four principal member types:

  • public: members that can be accessed from anywhere
  • private: members that can only be accessed from inside the object
  • privileged: members that can only be directly accessed from inside the object, but which can be indirectly accessed from outside via a public method
  • protected: members that can only be accessed from inside the object or any of its modules.

This article is not about object-orientation, because the structure we’re going to create is a kind of singleton, which is a single-instance structure that cannot be instantiated more than once. In fact, it isn’t instantiated at all (in the sense of having a constructor), so it’s an object-based rather than object-oriented pattern.

For more about the difference between object-based and object-oriented programming, and an introduction to object-orientated programming in JavaScript, I’d recommend Ryan Frishberg’s article: JavaScript Object-Oriented Programming.

Read More »

Events in the ASP.NET Request Life Cycle

09-08-2014

copied from the Programming Microsoft ASP.NET 4 book, Page 32, Charpter 2, Part 1.

Events are fired in the following sequence:

BeginRequest

The ASP.NET HTTP pipeline begins to work on the request. For the first request ever in the lifetime of the application instance, this event reaches the application after Application_Start.

AuthenticateRequest

The request is being authenticated. ASP.NET and IIS integrated authentication modules subscribe to this event and attempt to produce an identity.

If no authentication module produced an authenticated user, an internal default authentication module is invoked to produce an identity for the unauthenticated user. This is done for the sake of consistency so that code doesn’t need to worry about null identities.

Read More »

JavaScript undefined VS null

28-03-2014

Copied from here

undefined与null的区别

大多数计算机语言,都有一个表示“无”的值。

比如,C语言的NULL,Java的null,Python的none,Ruby的nil。有点奇怪的是JavaScript语言居然有两个表示“无”的值:undefined和null。

这是为什么?

Read More »