Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- keyword



  Python: calculate lighter/darker RGB colors

Many times color palettes have lighter and darker variations of the same color. This may be used to convey relative importance, or for something as simple as a gradient. Usually the designer will specify both colors. However, if you have a site that needs to allow user configurable styling, you may not want to ask the user for two variations of the same color. Here is some Python code to take a single color in RGB, and output an artitrarily lighter or darker variation of the same color...

   Python,RGC color,Calucaltion lighter/darker     2012-02-13 05:29:22

  Gracefully exiting from console programs in Ruby

Imagine you write a CLI program or a Rake task which loops through some data performing some work on it. You run it and then you remembered something. You’d love to kill the process with ctrl-c, but that will raise an exception somewhere in the loop. What you want is for the iteration to complete and then you want the program to quit. You could handle the Interrupt exception or add some conditions. But how about a cleaner and reusable way? No problem - you can trap signals, which...

   Ruby,Exit,Command window,Console,Graceful     2012-03-14 13:42:16

  this keyword in Lambda expression in Java 8

Since the release of Java 8, people are excited to see a big feature added to this language which is existing in other languages for a long time -- Lambda expression. The introduction of lambda expression in Java 8 gives people an easy way or a vertical to horizontal way to solve problems. There are many posts on the Internet which shows how to use lambda expression in Java, such as Lambda Quick Start and Java 8 Lambda Expressions Tutorial with Examples. In this post, we will only focus on the t...

   THIS,LAMBDA EXPRESSION,JAVA 8     2014-06-01 03:57:05

  A boolean value interview question

Someone asked a question on StackOverflow, he was asked an interview question. The question is : Given 3 boolean variables a, b, c, return true if at least 2 out of the 3 are true. He gave the solution as follows :boolean atLeastTwo(boolean a, boolean b, boolean c) {    if ((a && b) || (b && c) || (a && c)) {        return true;    } else {        ret...

   bool,return,expression,conditional     2012-04-30 08:49:32

  Interview Programming Problems Done Right

Introduction Why 37signals Doesn't Hire Programmers Based on Brainteasers and my comment on HN generated a lot of responses, so much so that I'm writing this post to properly explain the essence of a good (IMHO) interview programming problem. Pascal's Triangle Pascal's Triangle is a shortcut for getting coefficients most often used binomial probability. The root element is 1. Every other element is the sum of the one or two above it (diagonally left and diagonally right). There are severa...

   Interview,Programming problem,Pascal,Triangle     2012-01-06 09:46:43

  Error handling style in C

Following are three error handling styles in C.Which one you like the most? Or you don't like any one?1. /* Problem : Not enough. Easy to be wrong */int foo(int bar){        int return_value = 0;        int doing_okay = 1;        doing_okay = do_something( bar );        if (doing_okay)        { ...

   C,Error handling style,Goto,Nested if     2012-04-24 06:51:00

  The craziest Javascript implementations

Since its birth in 1994, Javascript has come a long way. Today it’s one of the most popular programming languages on the web because of high popularity of AJAX based web-applications. Also the rise of micro-frameworks such as jQuery (also Prototype, Moo Tools etc) which have reduced dramatically the complexity of code developers needed to write, it is well tested, has a ton of plug-ins, has a large development community and reduced development time.And lately even Server-S...

   JavaScript,Crazy implementation,JVM,Turing machine     2012-01-03 12:09:42

  this in JavaScript

this is a keyword in JavaScript. It refers to an internal object created automatically when a function executes, it can only be used in a function. For example:        function test(){     this.x = 1;   }The this keyword will change when a function is called in different situations. However, the general rule is : this refers to the object which calls the function.Next we discuss the use of this in 4 different situatio...

   this,keyword,use,JavaScript     2012-05-05 12:47:37

  Venn Diagram entirely in CSS

The HTML5 Microzone is presented by DZone and Microsoft to bring you the most interesting and relevant content on emerging web standards.  Experience all that the HTML5 Microzone has to offer on our homepage and check out the cutting edge web development tutorials on Script Junkie, Build My Pinned Site, and the HTML5 DevCenter. A friend of mine alerted me this weekend to just how much I have a weird fascination with Venn diagrams. I decided to roll with it. So yeah...

   CSS,Venn Diagram,Implementation     2012-02-06 08:10:41

  Magic CSS shape

There is a question on StackOverflow which states that someone finds a CSS sample on http://css-tricks.com/examples/ShapesOfCSS/  , the sample shows a triangle created with pure CSS. The source code is :#triangle-up {width: 0;height: 0;border-left: 50px solid transparent;border-right: 50px solid transparent;border-bottom: 100px solid red;}The question is how these few lines can create a triangle? Next we give the answer and the detail illustration to this question We need to consider the B...

   CSS,Triangle,Box model,Border     2012-04-20 12:56:22