Thursday, February 26, 2015

What CSS3 CANNOT DO

  1. CANNOT use multiple :before or :after pseudo-elements, but you can use both :before and :after at the same time.

  2. In this demo, the box element creates 5 round-corner rectangles (blue & red).
    The :before pseudo element creates 3 yellow circles.
    The :after pseudo element creates 3 green rectangles.
    You may be wondering why there are more than 3 shapes. It is the power of box-shadow.
    <style>
    .box {
      display: inline-block;
      /*overflow: hidden; */
      position: relative;
      border-radius: .7em;
      /* the lenght of height and width do not matter */
      height: 2em;
      width: 2em;
      margin: 80px 50px; 
      font-size: 1em;
      /* use 'em' as the unit as it's scalable. change font size to make the shape larger or smaller */
      box-shadow: 2em 2em 0 0 red, 2em -2em 0 0 red, -2em -2em 0 0 red, -2em 2em 0 0 red;
      background: blue;
    }
    .box:after {
      content: '';
      position: absolute;
      top: .5em;
      left: 2em;
      height: 1em;
      width: 1em;
      background: lime;
      box-shadow: 2em 2em 0 0 green, 2em -2em 0 0 green;
    }
    .box:before {
      content: 'a';
      position: absolute;
      top: .5em;
      left: -1em;
      height: 1em;
      width: 1em;
      background: yellow;
      border-radius: 1em;
      box-shadow: -2em -2em 0 0 orange, -2em 2em 0 0 orange;
    }
    </style>
    <div class="box"></div>
    
  3. CANNOT use counter inside cacl() function



Create a Successful Online Store at Bigcommerce! Try it Free Now!

Tuesday, February 24, 2015

HTML5 CSS3 Scrolling Slideshow | HTML 5 & CSS 3 - Smooth Scrolling

Smooth scrolling slideshow using pure CSS3 code

In this article, I'm going to demo how to implement image slideshow using
  1. CSS2 and Javascript
  2. CSS3
And for CSS3 approach, I'll show how to implement
  1. Scrolling up
  2. Scrolling up and down
If you move the mouse over and out the slideshow, it will be paused and resumed accordingly.
Keypoints in the demo includes:
  • setInterval and clearInterval
  • transform and translateY
  • calc
  • animation including animation-play-state
To simplify the example, all the images here are standard AD sidebar images (300px * 250px).

1. CSS2 + Javascript

Sponsors
<style type='text/css'>
 	#ad_container {
		margin-bottom: 10px;
		padding: 0;
		height: 304px;
		width: 304px;
		border: 2px solid rgb(111, 126, 255);
		box-shadow: 2px 2px 10px rgb(111, 126, 255);
		border-radius: 15px 15px 0 0;
		overflow: hidden;
	}
	#ad_title {
		margin: 0;
		padding: 0;
		height: 50px;
		line-height: 50px;
		font-size: 24px;
		color: white;
		text-align: center;
		background: rgb(111, 126, 255); 
	}
	#ad_content {
		margin: 5px auto;
		padding: 0;
		height: 250px;
		width: 300px;
		overflow: hidden;
	}

	#ad_content1, #ad_content2 {
		margin: 0;
		padding: 0;
		list-style-type: none;
	}
</style>
<div id='ad_container'>
		<div id='ad_title'>Sponsors</div>
		<div id='ad_content'>
			<ul id='ad_content1'>
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			<!-- MYADS CJ Web Hosting -->
				<li><a href='http://www.anrdoezrs.net/click-7744766-11793715' target='_top'>
	<img alt='' border='0' height='250' src='http://www.awltovhc.com/image-7744766-11793715' width='300'/></a></li>
			<!-- MYADS CJ Hotel -->
				<li><a href='http://www.jdoqocy.com/click-7744766-10691018' target='_top'> <img alt='Hotels.com' border='0' height='250' src='http://www.tqlkg.com/image-7744766-10691018' width='300'/></a></li>
			</ul>
			<ul id='ad_content2'/>
		</div>
</div>
<script>
	var ad_content = document.getElementById('ad_content');
	ad_content.scrollTop = 0;

	var ad_content1 = document.getElementById('ad_content1');
	var ad_content2 = document.getElementById('ad_content2');
	ad_content2.innerHTML = ad_content1.innerHTML;

	function scrollUp() {

		if (ad_content.scrollTop >= ad_content1.offsetHeight)
		{
			ad_content.scrollTop = '5px';
		}
		else
		{
			ad_content.scrollTop ++;
		}
	}
	
	var speed = 30;
	var myScroll = setInterval('scrollUp()', speed);
	
	ad_content.onmouseover = function(){
		clearInterval(myScroll);
	}
	ad_content.onmouseout = function(){
		myScroll = setInterval("scrollUp()", speed);
	}
</script>
To make it a smoothing sliding, we need to clone the content of ad_content1 to ad_content2, this is achieved by ad_content2.innerHTML = ad_content1.innerHTML in the Javascript.

2. CSS3

Sponsors
<style type='text/css'>
	#ad_container {
		margin: 100px;
		padding: 0;
		height: 304px;
		width: 304px;
		border: 2px solid rgba(111, 126, 255, 0.9);
		box-shadow: 2px 2px 10px rgba(111, 126, 255, 0.7);
		border-radius: 15px 15px 0 0;
		overflow: hidden;
	}
	#ad_title {
		padding: 0;
		height: 50px;
		line-height: 50px;
		font-size: 24px;
		color: white;
		text-align: center;
		background: rgba(111, 126, 255, 0.8); 
	}

	@-webkit-keyframes scroll-up {
		0%   {-webkit-transform: translateY(0);}
	    /* the height of each image is 250px, so 4 images have the height of 1000px */
	    100% {-webkit-transform: translateY(-75%);}
	}

	@keyframes scroll-up {
		0%   {transform: translateY(0);}
	    /* the height of each image is 250px, so 4 images have the height of 1000px */
	    100% {transform: translateY(-75%);}
	}

	#ad_content {
		margin: 5px auto;
		padding: 0;
		height: 250px;
		width: 300px;
		overflow: hidden;
	}
	#ad_content1 {
		margin: 0;
		padding: 0;
		list-style-type: none;
		-webkit-animation: scroll-up ease-in-out 10s infinite;
		animation: scroll-up ease-in-out 10s infinite;
	}
	#ad_content1:hover {
		-webkit-animation-play-state: paused;
		animation-play-state: paused;
	}
	#ad_content1 li {
		margin: 0 auto;
		padding: 0;
	}
</style>
<div id="ad_container">
		<div id="ad_title">Sponsors</div>
		<div id="ad_content">
			<ul id="ad_content1">
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			<!-- MYADS CJ Web Hosting -->
				<li><a href='http://www.anrdoezrs.net/click-7744766-11793715' target='_top'>
	<img alt='' border='0' height='250' src='http://www.awltovhc.com/image-7744766-11793715' width='300'/></a></li>
			<!-- MYADS CJ Hotel -->
				<li><a href='http://www.jdoqocy.com/click-7744766-10691018' target='_top'> <img alt='Hotels.com' border='0' height='250' src='http://www.tqlkg.com/image-7744766-10691018' width='300'/></a></li>
			<!-- repeat the first image for seamless scroll-up, remove this for scroll-up up and down -->
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			</ul>
			<ul id="ad_content2"></ul>
		</div>
</div>
CSS3 animation makes it eaiser to implement a smooth image scrolling. Moveover, since animation supports different timing functions, like linear and ease, you can create different animation effects. You can also combine other properties such as opacity in the animation.

The downside for the pure CSS3 solution is that we have to clone the first image and append it to the end manually in our HTML structure.

Another issue in this approach is that we hardcoded the translate offset in the CSS definition, i.e., 100% {transform: translateY(-75%);}. This can be solved by using a CSS3 function called calc(). So the above CSS can be replaced with 100% {transform: translateY(calc(250px - 100%));}. But do check the compatibility table for this function since it is quite new.

3. CSS3 (Scrolling up and down)

Sponsors
<style type='text/css'>
	#ad_container {
		margin: 100px;
		padding: 0;
		height: 304px;
		width: 304px;
		border: 2px solid rgba(111, 126, 255, 0.9);
		box-shadow: 2px 2px 10px rgba(111, 126, 255, 0.7);
		border-radius: 15px 15px 0 0;
		overflow: hidden;
	}
	#ad_container >#ad_title {
		padding: 0;
		height: 50px;
		width: 100%;
		line-height: 50px;
		font-size: 24px;
		color: white;
		text-align: center;
		background: rgba(111, 126, 255, 0.8); 
	}

	@-webkit-keyframes scroll-up-down {
	    0%   {transform: translateY(0);}
	    50% {transform: translateY(-webkit-calc(250px - 100%));}
	    100% {transform: translateY(0);}
	}

	@keyframes scroll-up-down {
	    0%   {transform: translateY(0);}
	    50% {transform: translateY(calc(250px - 100%));}
	    100% {transform: translateY(0);}
	}

	#ad_container >#ad_content {
		margin: 5px auto;
		padding: 0;
		height: 250px;
		width: 300px;
		overflow: hidden;
	}
	#ad_container >#ad_content >#ad_content1 {
		margin: 0;
		padding: 0;
		list-style-type: none;
		-webkit-animation: scroll-up-down ease-in-out 10s infinite;
		animation: scroll-up-down ease-in-out 10s infinite;
	}
	#ad_container >#ad_content >#ad_content1:hover {
		-webkit-animation-play-state: paused;
		animation-play-state: paused;
	}
	#ad_container >#ad_content >#ad_content1 li {
		margin: 0 auto;
		padding: 0;
	}
</style>
<div id="ad_container">
		<div id="ad_title">Sponsors</div>
		<div id="ad_content">
			<ul id="ad_content1">
			<!-- MYADS CJ Disney -->
				<li><a href='http://www.kqzyfj.com/click-7744766-11138523' target='_top'>
	<img alt='' border='0' height='250' src='http://www.tqlkg.com/image-7744766-11138523' width='300'/></a></li>
			<!-- MYADS CJ Web Hosting -->
				<li><a href='http://www.anrdoezrs.net/click-7744766-11793715' target='_top'>
	<img alt='' border='0' height='250' src='http://www.awltovhc.com/image-7744766-11793715' width='300'/></a></li>
			<!-- MYADS CJ Hotel -->
				<li><a href='http://www.jdoqocy.com/click-7744766-10691018' target='_top'> <img alt='Hotels.com' border='0' height='250' src='http://www.tqlkg.com/image-7744766-10691018' width='300'/></a></li>
			</ul>
		</div>
</div>


Create a Successful Online Store at Bigcommerce! Try it Free Now!

Tuesday, February 17, 2015

Windows7 Hibernate | Windows 7 Enable Hibernate

Follow these steps to enable Hibernate Option on Windows 7:

  1. Open command prompt window (press Win Key and "R" key at the same time and key in "cmd" in the popup and then press "Enter") and execute the command "powercfg -h on".

  2. Go to Control Panel -> Power Options, find the active power plan and click "Change plan settings".

  3. In the popup, find "Sleep > Allow hybrid sleep" option, then change the setting to "Off". (Must perform step 1, otherwise this option may not be visible.)

  4.  To deactivate Hibernate option, execute the command "powercfg -h off".


Create a Successful Online Store at Bigcommerce! Try it Free Now!

HTML5 CSS3 Yinyang Bagua | HTML 5 & CSS 3 - Create a Yinyang Bagua Diagram

Create a Yinyang Bagua diagram using pure CSS3 code:

figure
<meta charset="UTF-8">
<style>
.container {
  margin: 100px;
  position: relative;
  width: 137px;
  height: 137px;
  border-left: 2px solid black;
  border-bottom: 2px solid black;
  border-right: 2px solid white;
  border-top: 2px solid white;
  border-radius: 100%;
  -moz-transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

.yinyang {
  width: 136px;
  height: 136px;
  background: -moz-linear-gradient(45deg, white 0%, white 50%, black 51%, black 100%);
  background: -webkit-linear-gradient(45deg, white 0%, white 50%, black 51%, black 100%);
  background: linear-gradient(45deg, white 0%, white 50%, black 51%, black 100%);
  border-radius: 100%;
}

.yinyang::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 58px;
  left: 58px;
  background: white;
  border: 24px solid black;
  border-radius: 100%;
}

.yinyang::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 10px;
  left: 10px;
  background: black;
  border: 24px solid white;
  border-radius: 100%;
}

.yao {
  -moz-transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
  width: 68px;
  height: 24px;
  position: absolute;
  text-align: center;
}

.yao >div {
  margin: 0 auto;
  padding: 0;
  width: 60px;
  height: 5px;
  margin-bottom: 3px;
}

.qian {
  top: -25px;
  left: -45px;
}

.qian >.positive {
  background: rgb(0, 0, 0);
}

.kun {
  top: 135px;
  left: 115px;
  -moz-transform: rotate(135deg);
  -webkit-transform: rotate(135deg);
  transform: rotate(135deg);
}

.kun >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 40%, transparent 41%, transparent 59%, rgb(255, 255, 255) 60%, rgb(255, 255, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 40%, transparent 41%, transparent 59%, rgb(255, 255, 255) 60%, rgb(255, 255, 255) 100%);
  background: linear-gradient(90deg, rgb(255, 255, 255) 0%, rgb(255, 255, 255) 40%, transparent 41%, transparent 59%, rgb(255, 255, 255) 60%, rgb(255, 255, 255) 100%);
}

.li {
  top: 135px;
  left: -45px;
  -moz-transform: rotate(225deg);
  -webkit-transform: rotate(225deg);
  transform: rotate(225deg);
}

.li >.positive {
  background: rgb(0, 255, 0);
}

.li >.negative {
  background: -moz-linear-gradient(90deg, rgb(0, 255, 0) 0%, rgb(0, 255, 0) 40%, transparent 41%, transparent 59%, rgb(0, 255, 0) 60%, rgb(0, 255, 0) 100%);
  background: -webkit-linear-gradient(90deg, rgb(0, 255, 0) 0%, rgb(0, 255, 0) 40%, transparent 41%, transparent 59%, rgb(0, 255, 0) 60%, rgb(0, 255, 0) 100%);
  background: linear-gradient(90deg, rgb(0, 255, 0) 0%, rgb(0, 255, 0) 40%, transparent 41%, transparent 59%, rgb(0, 255, 0) 60%, rgb(0, 255, 0) 100%);
}

.kan {
  top: -25px;
  left: 115px;
  -moz-transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

.kan >.positive {
  background: rgb(255, 0, 255);
}

.kan >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 0, 255) 0%, rgb(255, 0, 255) 40%, transparent 41%, transparent 59%, rgb(255, 0, 255) 60%, rgb(255, 0, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 0, 255) 0%, rgb(255, 0, 255) 40%, transparent 41%, transparent 59%, rgb(255, 0, 255) 60%, rgb(255, 0, 255) 100%);
  background: linear-gradient(90deg, rgb(255, 0, 255) 0%, rgb(255, 0, 255) 40%, transparent 41%, transparent 59%, rgb(255, 0, 255) 60%, rgb(255, 0, 255) 100%);
}

.dui {
  top: 55px;
  left: -80px;
  -moz-transform: rotate(270deg);
  -webkit-transform: rotate(270deg);
  transform: rotate(270deg);
}

.dui >.positive {
  background: rgb(255, 0, 0);
}

.dui >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 0, 0) 0%, rgb(255, 0, 0) 40%, transparent 41%, transparent 59%, rgb(255, 0, 0) 60%, rgb(255, 0, 0) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 0, 0) 0%, rgb(255, 0, 0) 40%, transparent 41%, transparent 59%, rgb(255, 0, 0) 60%, rgb(255, 0, 0) 100%);
  background: linear-gradient(90deg, rgb(255, 0, 0) 0%, rgb(255, 0, 0) 40%, transparent 41%, transparent 59%, rgb(255, 0, 0) 60%, rgb(255, 0, 0) 100%);
}

.gen {
  top: 55px;
  left: 150px;
  -moz-transform: rotate(90deg);
  -webkit-transform: rotate(90deg);
  transform: rotate(90deg);
}

.gen >.positive {
  background: rgb(0, 255, 255);
}

.gen >.negative {
  background: -moz-linear-gradient(90deg, rgb(0, 255, 255) 0%, rgb(0, 255, 255) 40%, transparent 41%, transparent 59%, rgb(0, 255, 255) 60%, rgb(0, 255, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(0, 255, 255) 0%, rgb(0, 255, 255) 40%, transparent 41%, transparent 59%, rgb(0, 255, 255) 60%, rgb(0, 255, 255) 100%);
  background: linear-gradient(90deg, rgb(0, 255, 255) 0%, rgb(0, 255, 255) 40%, transparent 41%, transparent 59%, rgb(0, 255, 255) 60%, rgb(0, 255, 255) 100%);
}

.zhen {
  top: 170px;
  left: 35px;
  -moz-transform: rotate(180deg);
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}

.zhen >.positive {
  background: rgb(255, 255, 0);
}

.zhen >.negative {
  background: -moz-linear-gradient(90deg, rgb(255, 255, 0) 0%, rgb(255, 255, 0) 40%, transparent 41%, transparent 59%, rgb(255, 255, 0) 60%, rgb(255, 255, 0) 100%);
  background: -webkit-linear-gradient(90deg, rgb(255, 255, 0) 0%, rgb(255, 255, 0) 40%, transparent 41%, transparent 59%, rgb(255, 255, 0) 60%, rgb(255, 255, 0) 100%);
  background: linear-gradient(90deg, rgb(255, 255, 0) 0%, rgb(255, 255, 0) 40%, transparent 41%, transparent 59%, rgb(255, 255, 0) 60%, rgb(255, 255, 0) 100%);
}

.xun {
  top: -60px;
  left: 35px;
  -moz-transform: rotate(0deg);
  -webkit-transform: rotate(0deg);
  transform: rotate(0deg);  
}

.xun >.positive {
  background: rgb(0, 0, 255);
}

.xun >.negative {
  background: -moz-linear-gradient(90deg, rgb(0, 0, 255) 0%, rgb(0, 0, 255) 40%, transparent 41%, transparent 59%, rgb(0, 0, 255) 60%, rgb(0, 0, 255) 100%);
  background: -webkit-linear-gradient(90deg, rgb(0, 0, 255) 0%, rgb(0, 0, 255) 40%, transparent 41%, transparent 59%, rgb(0, 0, 255) 60%, rgb(0, 0, 255) 100%);
  background: linear-gradient(90deg, rgb(0, 0, 255) 0%, rgb(0, 0, 255) 40%, transparent 41%, transparent 59%, rgb(0, 0, 255) 60%, rgb(0, 0, 255) 100%);
}

</style>

<div class="container">  
  <div class="yinyang">
  </div>
  <div>
    <div class="qian yao">乾<div class="positive"></div><div class="positive"></div><div class="positive"></div></div>
    <div class="kun yao">坤<div class="negative"></div><div class="negative"></div><div class="negative"></div></div>
    <div class="li yao">离<div class="positive"></div><div class="negative"></div><div class="positive"></div></div>
    <div class="kan yao">坎<div class="negative"></div><div class="positive"></div><div class="negative"></div></div>
    <div class="dui yao">兑<div class="negative"></div><div class="positive"></div><div class="positive"></div></div>
    <div class="gen yao">艮<div class="positive"></div><div class="negative"></div><div class="negative"></div></div>
    <div class="zhen yao">震<div class="negative"></div><div class="negative"></div><div class="positive"></div></div>
    <div class="xun yao">巽<div class="positive"></div><div class="positive"></div><div class="negative"></div></div>
  </div>
</div>











Create a Successful Online Store at Bigcommerce! Try it Free Now!

Saturday, February 14, 2015

CSS Layout - Relative and Absolute Position

CSS Layout - Relative and Absolute

The position property is crucial to CSS layout. It has a couple of possible values. This article gives a simple example to help you understand the two most important values: relative and absolute.

CSS Sample

<style type="text/css">
.relative1 {
  position: relative;
  border: 1px solid red;
  color: red;
}
.relative2 {
  position: relative;
  top: -20px;
  left: 20px;
  width: 500px;
  border: 1px solid green;
  color: green;
}
.relative3 {
  position: relative;
  border: 1px solid orange;
  color: orange;
}
.absolute1 {
  position: absolute;
  top: -20px;
  left: 20px;
  width: 500px;
  border: 1px solid blue;
  color: blue;
}
.absolute2 {
  position: absolute;
  top: -20px;
  left: 20px;
  width: 500px;
  border: 1px solid black;
  color: black;
}
</style>
<div style="margin: 30px">
<div class="relative1"><p>relative1</p><p></p><p></p></div>
<div class="relative2"><p>relative2</p><p></p><p></p></div>
<div class="absolute1"><p>absolute1</p><p></p><p></p></div>
<div class="relative3"><p>relative3</p>
<div class="absolute2"><p>absolute2</p><p></p><p></p></div>
</div>
</div>


CSS Rules


There are two rules to remember:
  1. Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. In the example above, relative2 should be under relative1, however, since we set its top and left properties, it goes higher and to the left of its normal position. 
  2. A absolutely-positioned element is positioned relative to the nearest positioned ancestor (container). If an absolutely-positioned element has no positioned ancestors, it uses the document body. In the example above, absolute2 use relative3 as ancestor and adjusts accordingly. While absolute1 does not have an ancestor, so it adjusts according to the document.


Create a Successful Online Store at Bigcommerce! Try it Free Now!

Thursday, February 12, 2015

HTML5 CSS3 Moon | HTML 5 & CSS 3 - Create a Moon

CSS 3 Moon Code

The code below creates a red moon with animation:
<style>
.moon {
 margin: 50px 0 0 0;
 width: 200px;
 height: 200px;
}
.moon_left {
 width: 100px;
 height: 100px;
 background: red;
 border-radius: 50px;
}
.moon_right {
 width: 102px;
 height: 102px;
 top: -101px;
 left: -1;
 position: relative;
 background: white;
 border-radius: 50px;
 -webkit-animation: moon_right_position_change 5s ease-in 2s infinite alternate; /* Chrome, Safari, Opera */
 animation: moon_right_position_change 5s ease-in 2s infinite alternate;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes moon_right_position_change {
 25% {left: 25px;}
 50% {left: 50px;}
 100% {left: 100px;}
}

/* Standard syntax */
@keyframes moon_right_position_change {
 25% {left: 25px;}
 50% {left: 50px;}
 100% {left: 100px;}
} 

</style>
<div class="moon">
 <div class="moon_left"></div>
 <div class="moon_right"></div>
</div>


Create a Successful Online Store at Bigcommerce! Try it Free Now!

HTML5 CSS3 Star | HTML 5 & CSS 3 - Create a Pentagram

CSS3 Pentagram (Five-Pointed Star) Code
The code below creates a yellow star
<style>

/* Chrome, Safari, Opera */
@-webkit-keyframes pentagram_animation {
 0% {-webkit-transform: rotate(0deg);}
 25% {-webkit-transform: rotate(90deg);}
 50% {-webkit-transform: rotate(180deg);}
 75% {-webkit-transform: rotate(270deg);}
 100% {-webkit-transform: rotate(360deg);}
}

/* Standard syntax */
@keyframes pentagram_animation {
 0% {transform: rotate(0deg);
 -ms-transform: rotate(0deg);}
 25% {transform: rotate(90deg);
 -ms-transform: rotate(90deg);}
 50% {transform: rotate(180deg);
 -ms-transform: rotate(180deg);}
 75% {transform: rotate(270deg);
 -ms-transform: rotate(270deg);}
 100% {transform: rotate(360deg);
 -ms-transform: rotate(360deg);}
} 

.pentagram {
 margin: 120px 0 0 0;
 width: 200px;
 height: 200px;
 -ms-transform-origin: 55px 15px; /* IE 9 */
    -webkit-transform-origin: 55px 15px; /* Chrome, Safari, Opera */
    transform-origin: 55px 15px;
 -webkit-animation: pentagram_animation 5s linear 1s infinite normal; /* Chrome, Safari, Opera */
 animation: pentagram_animation 5s linear 1s infinite normal;
}
.pentagram_top {
 width: 0;
 height: 0;
 border-top: 34px solid yellow;
 border-left: 55px solid transparent;
 border-right: 55px solid transparent;
}
.pentagram_left {
 width: 0;
 top: -34px;
 position: relative;
 border-top: 34px solid yellow;
 border-left: 55px solid transparent;
 border-right: 55px solid transparent;
 transform: rotate(72deg);
 -ms-transform: rotate(72deg);
 -webkit-transform: rotate(72deg);
}
.pentagram_right {
 width: 0;
 top: -68px;
 position: relative;
 border-top: 34px solid yellow;
 border-left: 55px solid transparent;
 border-right: 55px solid transparent;
 transform: rotate(-73deg);
 -ms-transform: rotate(-73deg);
 -webkit-transform: rotate(-73deg);
}
</style>
<div class="pentagram">
 <div class="pentagram_top"></div>
 <div class="pentagram_left"></div>
 <div class="pentagram_right"></div>
</div>



Create a Successful Online Store at Bigcommerce! Try it Free Now!

Tuesday, February 10, 2015

XML - WstxParsingException: Illegal processing instruction target ("xml")

I got the following error when I was restarting JBoss AS 7.
com.ctc.wstx.exc.WstxParsingException: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.

JBoss complained it could not parse the standalone.xml.
Soon I realized that I accidentally added a empty line before the xml declaration. Something like:
[empty line]
<?xml version="1.0" encoding="utf-8"?>
[other xml content]
So please keep in mind whenever you encounter this error, do check your xml file and put the xml declaration as the first line of the file.


Create a Successful Online Store at Bigcommerce! Try it Free Now!

Sunday, February 8, 2015

HTML5 CSS3 Triangle | HTML 5 & CSS 3 - Create a Triangle

CSS 3 Triangle Code


The code below creates a black triangle

<style>
.triangle {
 width: 0;
 height: 0;
 border-left: 50px solid transparent;
 border-right: 50px solid transparent;
 border-bottom: 100px solid black;
}
</style>
<div class="triangle"></div>


CSS3 Add Border Color

If we give the borders a color, what will happen?
<style>
.triangle2 {
 width: 0;
 height: 0;
 border-left: 50px solid red;
 border-right: 50px solid blue;
 border-bottom: 100px solid black;
}
</style>
<div class="triangle2"></div>



Create a Successful Online Store at Bigcommerce! Try it Free Now!

Friday, February 6, 2015

RadRibbonBar Application Menu | Telerik Winforms 2010 SP1 - RibbonBar - Hide the Application Menu Button

RadRibbonBar Default View

Telerik Winforms provides a RibbonBar control you can build user interfaces similar to those used in Microsoft Office 2007. The control has an Application Menu Button which is located on the upper left corner as shown below:


Sometimes you may want to hide the Application Menu Button. If you change its size to 0, you will get an error. While if you change its size to 1 (the minimal possible value), you will get something like:

Remove Application Menu Button From RadRibbonBar

To completely hide the button, try this:

this.RibbonBarElement.ApplicationButtonElement.Visibility = ElementVisibility.Collapsed;


Create a Successful Online Store at Bigcommerce! Try it Free Now!

Wednesday, February 4, 2015

RadGridView Multiple Columns Sorting | Telerik Winforms 2010 SP1 - RadGridView - Multiple Columns Sorting

RadGridView supports multiple columns sorting in three ways:

RadGridView Multiple Columns Sorting at Design Time

At design time, you can enable multiple columns sorting following these steps:
  1. Open designer view in Visual Studio;
  2. Right click and then select "Open Property Builder" in the context menu;
  3. In the property builder, select "GridViewTemplate" on the left pane;
  4. Select "Advanced" tab on the right pane;
  5. Search for "SortExpressions" in the property window below and then click the button on the right;
  6. In the "GridSortField Collection Editor" dialog, add columns to be sorted.

RadGridView Multiple Columns Sorting By Program

You can enable multiple columns sorting programmatically; following these steps described here

RadGridView Multiple Columns Sorting at Runtime

At runtime, you can enable multiple columns sorting by holding "Shift" key and click on the headers of the columns to be sorted.
gridview-sorting-setting-sorting-programmatically 001



Create a Successful Online Store at Bigcommerce! Try it Free Now!

C# - Convert Java Time (in Milliseconds) to Windows Time

Assume you have a frontend built with C# and a backend built with Java. In a grid view you want to display some data from a database table and one column uses numeric format to store date/time values.

If you simply do like the following way, you will get wrong answer.
  DateTime dateTime = DateTime.FromFileTime(javaTime);

  return dateTime.ToString("yyyy-MM-dd HH:mm:ss");

To get correct answer, use this code:

private static DateTime WINDOWS_EPOCH = new DateTime(1601, 1, 1, 0, 0, 0);
private static DateTime JAVA_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0);

public static String FromJavaTime(long javaTime, string timeFormat)
{
  long epochDiff = (JAVA_EPOCH.ToFileTimeUtc() - WINDOWS_EPOCH.ToFileTimeUtc()) / TimeSpan.TicksPerMillisecond;

  DateTime dateTime = DateTime.FromFileTime((javaTime + epochDiff) * TimeSpan.TicksPerMillisecond);

  return dateTime.ToString(timeFormat);
}

Then if you run FromJavaTime(1420621059959, "yyyy-MM-dd HH:mm:ss"), you will get "2015-01-07 16:57:39".



Create a Successful Online Store at Bigcommerce! Try it Free Now!

Microsoft Excel - Create A Mulplication Table

The formula that you need for the multiplication table is a formula that will multiply whatever is in row 1 by whatever is in column A.
To have a reference that always points to row 1, use something in the format of X$1. To have a reference that points to column A, use a reference in the format of $An.

First, create something like:

Then enter $A2*B$1 into B2.

Next, copy the formula in B2 to the entire area and you will get the expected output:



Create a Successful Online Store at Bigcommerce! Try it Free Now!

Tuesday, February 3, 2015

Ganymed SSH2 Cisco Router | Using Ganymed SSH2 to Configure Cisco Routes/Switches

Configure Cisco Routers/Switches Using SSH

I have some use cases where SSH is used to configure Cisco routers/switches. For example, to enable a WAN interface, the following commands are executed:
en
password
configure terminal 
int Fa0/0/0
ip address 172.0.0.1255.255.255.252
description Link to 408
bandwidth 8000
service-policy output shape-8Mb
no shutdown
end

copy run start
exit
 

Apache Camel SSH Component

Apache Camel has a SSH component. However, I found that it did not work when configuring Cisco routers/switches.
The problem is that it cannot execute the "en password" command.

Ganymed SSH2 Library

Fortunately I could solve it by using another SSH library called Ganymed.
The following is the code I used to execute IOS commands.

 



private static final String PROMPT_SYMBOL = "%";
private static final char ERROR_SYMBOL = '^';
private static final String ACCESS_DENIED_MESSAGE = "Access denied";
private static final int MAX_OUTPUT_BUFFER_SIZE = 1024 * 1024;

public void executeCommand(String host, String username, String password, int timeout, String command) throws IOException, AccessDeniedException
{
  Connection connection = new Connection(host);
  
  connection.connect(null, timeout, timeout);
  
  boolean authenticated = connection.authenticateWithPassword(username, password);
  
  if (!authenticated)
    return;
  
  Session session = connection.openSession();
  session.startShell();
  
  executeCommand(session, timeout, command);
}
Hotels.com 
private SshResponse executeCommand(Session session, int timeout, String command) throws IOException, AccessDeniedException
{
  OutputStream in = session.getStdin();

  in.write(command.getBytes());
  
  InputStream stdout = session.getStdout();
  InputStream stderr = session.getStderr();
  
  StringBuilder sb = new StringBuilder();
  boolean valid = false;
  String line = null;

  boolean flag = true;
  while (flag)
  {
    int conditions = session.waitForCondition(ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA | ChannelCondition.EOF, timeout);

    if ((conditions & ChannelCondition.TIMEOUT) != 0)
    {
      break;
    }

    if ((conditions & ChannelCondition.EOF) != 0)
    {
      if ((conditions & (ChannelCondition.STDOUT_DATA | ChannelCondition.STDERR_DATA)) == 0)
      {
        break;
      }
    }

    BufferedReader reader = null;
    try
    {
      if ((ChannelCondition.STDOUT_DATA & conditions) != 0)
      {
        reader = new BufferedReader(new InputStreamReader(stdout));
      }
      else
      {
        reader = new BufferedReader(new InputStreamReader(stderr));
      }

      //Reader.readLine() may hang if 'exit' is not added to the command as the last line (use the 'exit' to exit the shell)
      
      boolean toAppend = true;
      
      while (true)
      {
        line = reader.readLine();
        
        if (line == null)
        {
          valid = true;
          
          flag = false;
          break;
        }
        
        if (toAppend)
        {
          toAppend = this.append(sb, line);
        }
        
        if (line.trim().startsWith(PROMPT_SYMBOL))
        {
          if (line.trim().indexOf(ERROR_SYMBOL) >= 0)
          {
            valid = false;
            
            flag = false;
            break;
          }
          else if (line.trim().contains(ACCESS_DENIED_MESSAGE))
          {
            throw new AccessDeniedException(line.trim());
          }
        }
        
        line = reader.readLine();
      }
    }
    finally
    {
      if (reader != null)
        reader.close();
    }
  }
  
  String message = sb.toString().trim();
  
  SshResponse response = new SshResponse();
  
  response.setCommand(command);
  response.setValid(valid);
  response.setOut(message);
  //keep all output
  //r4(config)#int Fastethernet1/0
  //               ^
  //% Invalid input detected at '^' marker.
  response.setErr(message);
  
  return response;
}
private boolean append(StringBuilder sb, String line)
{
  if (sb.length() >= MAX_OUTPUT_BUFFER_SIZE)
  {
    sb.setLength(MAX_OUTPUT_BUFFER_SIZE - 3);
    sb.append("...");
    
    return false;
  }
  
  if (sb.length() + line.length() > MAX_OUTPUT_BUFFER_SIZE)
  {
    //Minimum abbreviation width is 4
    if (MAX_OUTPUT_BUFFER_SIZE - sb.length() < 4)
    {
      sb.setLength(MAX_OUTPUT_BUFFER_SIZE - 3);
      sb.append("...");
    }
    else
    {
      String abbreviated = StringUtils.abbreviate(line, MAX_OUTPUT_BUFFER_SIZE - sb.length());
      
      sb.append(abbreviated);
    }
    
    sb.append('\n');
    
    return false;
  }
  
  sb.append(line);
  sb.append('\n');
  
  return true;
}

Keep in mind that the last command "exit" should not be omitted otherwise the SSH session may hang up for ever.


Create a Successful Online Store at Bigcommerce! Try it Free Now!