IMG-LOGO

Tutorial

IMG
Angular JS Service
15 Feb-2020

What is Angular JS Service?

A service is a function/object, that is available for and limited to your AngularJS application.

Angular JS has 30 built-in services.

The $location service is one of them and it has methods which return information about the location of the current web page:

Example

You can use $location service in a controller:

var app = angular.module(FirstApp, []);
app.controller(custCtrl, function($scope, $location) {
    $scope.FirstUrl = $location.absUrl();
});

Noted:  $location service is passed in to the controller as an argument. In order to use the service in the controller, it must be defined as a dependency.

Why use Services?

For many services, like the $location service, it seems like you could use objects that are already in the DOM, like the window.location object, and you could, but it would have some limitations, at least for your AngularJS application.

 

AngularJS constantly supervises your application, and for it to handle changes and events properly, AngularJS prefers that you use the $location service instead of the window.location object.

 

The $http Service

The $http service is one of the most common used services in AngularJS applications. The service makes a request to the server, and lets your application handle the response.

 

Example

Use the $http service to request data from the server:

var app = angular.module(FirstApp, []);
app.controller('myCtrl', function($scope, $http) {
  $http.get("welcome.htm").then(function (response) {
    $scope.Welcome = response.data;
  });
});

This example demonstrates a very simple use of the $http service. Learn more about the $http service in the AngularJS Http Tutorial.

 

The $timeout Service

The $timeout service is AngularJS' version of the window.setTimeout function.

 

Example

Display a new message after two seconds:

var app = angular.module(FirstApp, []);
app.controller('myCtrl', function($scope, $timeout) {
  $scope.myHeader = "Hello World!";
  $timeout(function () {
    $scope.myHeader = "How are you today?";
  }, 2000);
});

The $interval Service

The $interval service is AngularJS' version of the window.setInterval function.

 

Example

Display the time every second:

var app = angular.module(FirstApp, []);
app.controller('myCtrl', function($scope, $interval) {
  $scope.theTime = new Date().toLocaleTimeString();
  $interval(function () {
    $scope.theTime = new Date().toLocaleTimeString();
  }, 1000);
});

Create Your Own Service

To create your own service, connect your service to the module:

Create a service named hexafy:

app.service('hexafy', function() {
  this.myFunc = function (x) {
    return x.toString(16);
  }
});

To use your custom made service, add it as a dependency when defining the controller:

Example

Use the custom made service named hexafy to convert a number into a hexadecimal number:

app.controller('myCtrl', function($scope, hexafy) {
  $scope.hex = hexafy.myFunc(255);
});

Use a Custom Service Inside a Filter

Once you have created a service, and connected it to your application, you can use the service in any controller, directive, filter, or even inside other services.

To use the service inside a filter, add it as a dependency when defining the filter:

The service hexafy used in the filter myFormat:

 
app.filter('myFormat',['hexafy', function(hexafy) {
  return function(x) {
    return hexafy.myFunc(x);
  };
}]);

 

News

IMG
Galaxy Z Flip phone ?
News 15 Feb-2020

New York (CNN Business) A week ago, it'd be easy to dismiss foldable smartphones as a trend that never became a full-on fad. After all, Samsung's Galaxy Fold model, at nearly $2,000, famously broke for early reviewers, and the newly-launched $1,500 Motorola RAZR flip phone -- twice the cost of an iPhone 11 -- touts mostly lackluster features, including a small battery and plastic screen.

But Samsung's Galaxy Z Flip phone, announced Tuesday at a press event in San Francisco, could be the device that breathes new life into the buzzy concept that borrows heavily from designs of the past.

The 6.7-inch smartphone folds into a square about half its size, with a small rectangular display on the front cover for notifications. It comes in three colors — purple, black and gold — and goes on sale Friday February 14 in select stores and online.

At $1,380, the Z Flip is far from affordable, but with a new, sturdier design and almost as much computing power as the Samsung (SSNLF) flagship smartphone, the company could be onto something.

Galaxy Z Flip phone is seen at Samsung's Galaxy UNPACKED at The Palace of Fine Arts on February 11, 2020 in San Francisco, California. (Photo by Kelly Sullivan/Getty Images for Samsung Electronics America)

Galaxy Z Flip phone is seen at Samsung's Galaxy UNPACKED at The Palace of Fine Arts on February 11, 2020 in San Francisco, California. (Photo by Kelly Sullivan/Getty Images for Samsung Electronics America)

"After years of complacency in the smartphone market, waiting for some design innovation, there is little doubt that foldable smartphones are set to become the next technology innovation trend," said David McQueen, research director at tech advisory firm ABI Research. "Despite the obvious and immediate issues with getting them to market -- notably high barriers to entry, extreme hardware innovation, seamless user experiences and current eye-wateringly high prices -- foldable displays are set to become an important form factor in future product portfolios bringing much needed innovation into device design."

 

Beyond the nostalgia factor, there's a lot of appeal in a phone that shrinks in size and shuts close. At a time when smartphones light up and scream for us to grab them with each notification, snapping the device down is a refreshing change. (Like the RAZR, the Z Flip features a small display on the front so you can still see notifications come through if closed.)

Upon first impression, the Z Flip is the clear standout in the emerging foldable phone wars. Unlike the RAZR's plastic display, the Z Flip features a layer of ultra-thin glass that opens and snaps into place with ease. It packs a powerful processor and decent battery life and does most of what you'd expect from a smartphone these days. The Galaxy Z Flip stays true to its name by adopting the clamshell design typical of flip phones (the Galaxy Fold folded vertically outward, similar to a book).

The change to the hinge here is critical: It now features a small, internal brush-like system to push out debris and opens and snaps into place with ease. (Samsung claims it can open up to 200,000 times without damage.)

The downside of making the hinge horizontal, however, is a noticeable crease that resides in the center of the display, where users are often swiping and opening apps; you can both see it and feel it. It's a reminder that manufacturers are still trying to figure out how to approach the design. It's rumored that Apple could be working on a foldable concept, as well.

 

But for now, it's hard to get over the price -- something that will likely pigeonhole it as a niche product. It's only $20 less than the high-end Samsung Galaxy S20 Ultra, which boasts 5G capabilities, a super responsive touchscreen and an incredibly powerful set of cameras. Considering the Flip Z's price is $600 less than the Galaxy Fold, it signals Samsung is trying to figure out its place in the market.

Another key factor in determining the price is materials; the original Fold was basically two thin smartphones sandwiched on top of each other.

"This time it's one smartphone cut in half, so there are some price savings to be had," said Ramon Llamas, a director at research firm IDC. "Samsung continues to see an opportunity to differentiate itself in an otherwise copycat market and still make some money off of it. It already has the innovation chops and the manufacturing capabilities to do this themselves, and it's practically a category that it can claim as its own until foldables gain greater salience. That's a strong position for Samsung."

But could flip phones once again be the next big category of devices? For now, that may be a leap, but if executed correctly, Z Flip's "wow" factor will entice early adopters and eventually a larger audience. Get the price tag down to three digits, and things could get very interesting.

"For most consumers, phones have become predictable, boring and uninspiring. Standing out is not a bad thing," said Ben Stanton, senior analyst at tech market firm Canalys.

 

Collected From CNN EDITOR

IMG
Free Windows 7
News

The Free Software Foundation wants Microsoft to keep Windows 7 alive as a free operating system. Microsoft stopped providing free security patches and support for Windows 7 earlier this month.

Although the popular operating system reached its 10th birthday last fall, some 200 million PCs around the globe still run it, according to industry estimates. Users include small business owners, some larger companies, government agencies, and hordes of consumers worldwide.

Microsoft expects most Windows 7 users to migrate to Windows 10, but it continues to provide patches and support for Windows 7 Pro and Enterprise, which are eligible for extended security update support for three years, for a fee. Windows 7 Home editions and Ultimate editions are not included in the options to purchase extended support.

The FSF this week launched the "Upcycle Windows 7" petition. The organization is still collecting signatures, though it has surpassed its goal of getting 7,777 people to sign on to make Windows 7 available for free. The current tally is approaching 10,000.

Making the OS free would allow users "the freedom to run, copy, distribute, study, change and improve the software," according to the foundation.

The petition makes no reference to who would maintain the free version with necessary patchs and continued upgrades, if any.

Making Windows 7 free could be viable, said Charles King, principal analyst at Pund-IT.

"At this point, the likelihood of converting current Windows 7 users to Windows 10 seems nil. Releasing the OS could earn Microsoft the goodwill of those users, and might lead to projects that would help ensure the continuing viability and security of Windows 7," he told LinuxInsider.

Not Just

The petition's wording is to demand rather than simply ask that the company release Windows 7 as free software. The petition asserts that Microsoft ended "10 years of poisoning education, invading privacy, and threatening user security."

Windows 7's end of lifecycle gives Microsoft "the perfect opportunity to undo past wrongs, and to upcycle it instead," it states.

A precedent for releasing some core Windows utilities as free software already exists, according to the petition. So Microsoft would lose nothing "by liberating a version of their operating system that they themselves say has reached its end."

Microsoft released code for the Windows Calculator. So it can do the same for Windows 7, according to the foundation.

Also, Microsoft released MS-DOS five years ago as downloadable code. However, using it is limited to the terms of a noncommercial-use license agreement.

Given Microsoft's growing prominence in open source, and its ownership of GitHub, releasing the Windows 7 code as open source also could be beneficial to Microsoft.

It could be positioned as "putting our money where our mouth is," King noted. Many in the open source community would welcome that.

Responses Divided

From Microsoft's perspective, releasing Windows 7 might not be as straightforward as one might expect. For typical consumers, Windows 7 already was free since it came bundled with their computers.

Microsoft is a for-profit company. That means it incurs costs to develop software for commercial use. The for-profit model is the foundation of the company, said Maryanne Steidinger, head of marketing for Webalo.

"IF they have no additional development costs -- services, support, troubleshooting -- around Windows 7, that might be a consideration to make it freeware, but then they should cut all support and let the market take the calls. I don't think anyone would want that," she told LinuxInsider.

The proprietary OS still has considerable market share to consider. Win 7's market share is expected to be 35 percent in 2020 and 28 percent in 2021, Steidinger added.

"So that endears users to keep it and maintain it," she said. "Because of the continuing market share and revenue generation for Windows 7, I think the company will say no."

It would be great if Microsoft released Windows 7 as freeware, but it is not a sure bet that the company will respond favorably to the petition, said Michael Arman, economic development director for the City of Oak Hill, Florida.

"Microsoft is not known for their charity, and there is plenty of code in Windows 7, which is used in 10 and in various other flavors of Microsoft's software. Why should they give that away when they can sell it?" he told LinuxInsider.

Corporate Signals is Mixed

Microsoft declined our request to comment on the FSF's petition.

However, over the last few years, Microsoft executives have suggested that open sourcing some of its software titles was not out of the question.

A future version of Windows released as open source was "definitely possible," Microsoft's Mark Russinovich said at ChefConf 2015 in Santa Clara, California.

Microsoft should release Windows 7 code under a free software license to prove that its love of open source software is not just a vehicle to "exploit users," the foundation argues in the petition.

The foundation did not respond to LinuxInsider's request for clarification on the petition.

Why Keep Working?

For government agencies, consumers, and businesses still using Windows 7, the main reason to keep Windows 7 alive is a no-brainer. "It just works" is the common battle cry.

Upon its introduction, Windows 7 was a very good, highly stable OS that corrected most of the mistakes Microsoft made with Vista, Pund-IT's King pointed out.

"It still fills the bill for numerous Windows and applications, so satisfied consumers and businesses see little if any reason to change. This has been a recurring issue for past Microsoft OSes, including Windows 3.1, NT and XP, and I expect it will continue so long as Microsoft remains an OS vendor," he said.

Some Windows 7 users go even further in their continued praise for the out-of-date OS. It still works with an assortment of equipment and software that may not be compatible with Windows 10.

"Everyone who uses it has more or less gotten it figured out and is comfortable with it," Oak Hill's Arman emphasized.

"There is also a HUGE installed base of Windows 7 software in business applications, and in many cases drivers for custom applications to interface with Windows 10 have not been written and may never be written," he said.

The ONLY thing "wrong" with Windows 7 is that Microsoft no longer supports it. That will make it increasingly vulnerable to malware, said Arman.

"If the machine is not connected to the Internet, there is NO reason to make the change," he added. "Windows 7 is now effectively out of warranty, such as it was. That doesn't mean it won't work."

 

Collected:

IMG
Reduce Your Physical Risk using VR - ( Virtual Reality Causing Injuries )
News

Carpal tunnel, stiff shoulders, eye-strain headaches ­­– these are all well-known side effects of prolonged computer use. But what happens when you step away from the desktop and into virtual reality?

A recent study from Oregon State University assessed how some common virtual reality movements contribute to muscle strain and discomfort. It’s an effort to ensure future user safety in this fast-growing technology that is used not only for gaming, but also increasingly for education and industrial training.

“There are no standards and guidelines for virtual and augmented reality interactions,” said researcher Jay Kim of OSU’S College of Public Health and Human Sciences. “We wanted to evaluate the effects of the target distances, locations, and sizes so we can better design these interfaces to reduce the risk for potential musculoskeletal injuries.”

The study was published recently in Applied Ergonomics with Northern Illinois University co-authors Sai Akhil Penumudi, Veera Aneesh Kuppam and Jaejin Hwang.

Virtual reality users wear a headset and engage in full-body, three-dimensional movements – unlike conventional computer users, where a desk or the arms of a chair offer some level of support for the hands and arms.

With sensors placed on participants’ joints and muscles, researchers used motion capture to record their movements and electromyography to measure electrical activity in their muscles while performing common VR gestures. Wearing an Oculus Rift VR headset, participants were tasked with either pointing to specific dots around a circle, or coloring in a certain area with their finger.

 

Researchers repeated the tests with the visuals placed at eye level, 15 degrees above eye level, 15 degrees below eye level and 30 degrees below eye level.

Regardless of the angle, extending the arm straight out causes shoulder discomfort in as little as three minutes, Kim said. With prolonged use, as VR often requires, this may lead to major health problems like gorilla arm syndrome and rotator cuff injuries.

In addition, the heavy VR headset may increase the burden on the cervical spine, risking greater neck strain.

In computer users, the relationship between awkward postures or repeated movements and musculoskeletal disorders is well known, Kim said. “We wanted to see how the VR compares to conventional computer-human interactions.”

The goal of the study was to establish a baseline of optimal object placement and angles, so VR developers going forward can design games and programs that minimize user discomfort.

Researchers focused on neck and shoulder movements. They found performance in the coloring task was worst when participants had to tilt their heads down 15 and 30 degrees. The most extreme postures and highest muscle activity were observed with targets at 15 degrees above eye level, as participants were forced to constantly maintain their extended neck and elevated arm position. And discomfort was greatest in the pointing task at 15 degrees above eye level.

“Based on this study, we recommend that objects that are being interacted with more often should be closer to the body,” Kim said. “And objects should be located at eye level, rather than up and down.”

The findings could have a massive impact, given VR’s growing demand: Tech analysts project that roughly 168 million people worldwide will have some form of VR installed by 2023. A major portion of users are gamers, but VR’s practical applications extend to health care, the military, education, and training. In coal mining, for example, trainees use VR to practice new skills that would be dangerous to learn on-site.

 

Kim’s main goal is to avoid the mistakes of the past. When personal computing was first emerging in the ’80s and ’90s, he said, people often didn’t think of the risks of overuse until it was too late.

With VR, he said, “We’d like to learn now rather than later.”

Reference: “The effects of target location on musculoskeletal load, task performance, and subjective discomfort during virtual reality interactions” by Sai Akhil Penumudi, Veera Aneesh Kuppam, Jeong Ho Kim and Jaejin Hwang, 27 November 2019, Applied Ergonomics.

DOI: 10.1016/j.apergo.2019.103010

Course

IMG
CSS Border -
Course - 19 Jun-2019

Properties of CSS Border

Properties of CSS border, allow your style is specify, width, and color of a border element's.

Such as

All sides borders have on.

Red bottom border I have

Rounded borders I have.

Blue left border I have a.

Border Style

The border-style property specifies what kind of border to display.

The listed following values are accepted:

  1. dotted - Defines a dotted border
  2. dashed - Defines a dashed border
  3. solid - Defines a solid border
  4. double - Defines a double border
  5. groove - Defines a 3D grooved border. The effect depends on the border-color value
  6. ridge - Defines a 3D ridged border. The effect depends on the border-color value
  7. inset - Defines a 3D inset border. The effect depends on the border-color value
  8. outset - Defines a 3D outset border. The effect depends on the border-color value
  9. none - Defines no border
  10. hidden - Defines a hidden border

The border-style property can have from one to four values (for the top border, right border, bottom border, and the left border).

Example

p.dotted {border-style: dotted;}

p.dashed {border-style: dashed;}

p.solid {border-style: solid;}

p.double {border-style: double;}

p.groove {border-style: groove;}

p.ridge {border-style: ridge;}

p.inset {border-style: inset;}

p.outset {border-style: outset;}

p.none {border-style: none;}

p.hidden {border-style: hidden;}

p.mix {border-style: dotted dashed solid double;}

Output:

  • A dotted border.
  • A dashed border.
  • A solid border.
  • A double border.
  • A groove border. The effect depends on the border-color value.
  • A ridge border. The effect depends on the border-color value.
  • An inset border. The effect depends on the border-color value.
  • An outset border. The effect depends on the border-color value.
  • No border.
  • A hidden border.
  • A mixed border.

Note: None of the OTHER CSS border properties described below will have ANY effect unless the border-style property is set!

Border Width

The border-width property specifies the width of the four borders.

The width can be set as a specific size (in px, pt, cm, em, etc) or by using one of the three pre-defined values: thin, medium, or thick.

The border-width property can have from one to four values (for the top border, right border, bottom border, and the left border).

6px border-width

Example

p.first {
border-style: solid;
border-width: 5px;
}
p.second {
border-style: solid;
border-width: medium;
}
p.third {
border-style: solid;
border-width: 2px 10px 4px 20px;
}

Border Color

The border-color property is used to set the color of the four borders.

The color can be set by:

name - specify a color name, like "red"

Hex - specify a hex value, like "#ff0000"

RGB - specify a RGB value, like "rgb(255,0,0)"

transparent

The border-color property can have from one to four values (for the top border, right border, bottom border, and the left border).

If border-color is not set, it inherits the color of the element.

Example

p.one {
border-style: solid;
border-color: red;
}
p.two {
border-style: solid;
border-color: green;
}
 
p.three {
border-style: solid;
border-color: red green blue yellow;
}

Border - Individual Sides

From the examples above you have seen that it is possible to specify a different border for each side.

In CSS, there are also properties for specifying each of the borders (top, right, bottom, and left):

Different Types of Border Styles

Example

p {
border-top-style: dotted;
border-right-style: solid;
border-bottom-style: dotted;
border-left-style: solid;
}

Example

p {
border-style: dotted solid;
}
So, here is how it works:

If the border-style property has four values:

border-style: dotted solid double dashed;

top border is dotted

right border is solid

bottom border is double

left border is dashed

If the border-style property has three values:

border-style: dotted solid double;

top border is dotted

right and left borders are solid

bottom border is double

If the border-style property has two values:

border-style: dotted solid;

top and bottom borders are dotted

right and left borders are solid

If the border-style property has one value:

border-style: dotted;

all four borders are dotted

The border-style property is used in the example above. However, it also works with border-width and border-color.

Border - Shorthand Property

As you can see from the examples above, there are many properties to consider when dealing with borders.

To shorten the code, it is also possible to specify all the individual border properties in one property.

The border property is a shorthand property for the following individual border properties:

border-width

border-style (required)

border-color

Example

p {
border: 5px solid red;
}
You can also use border properties for just one side:
Left Border
p {
border-left: 5px solid red;
background-color: lightgrey;
}

 

Bottom Border

p {
border-bottom: 6px solid red;
background-color: lightgrey;
}

Rounded Borders

The border-radius property is used to add rounded borders to an element:

Normal border

Round border

Rounder border

Roundest border

Example

p {
border: 2px solid red;
border-radius: 5px;
}

Note: The border-radius property is not supported in IE8 and earlier versions.

More Examples

All the top border properties in one declaration

This example demonstrates a shorthand property for setting all of the properties for the top border in one declaration.

 

Set the style of the bottom border

This example demonstrates how to set the style of the bottom border.

 

Set the width of the left border

This example demonstrates how to set the width of the left border.

 

Set the color of the four borders

This example demonstrates how to set the color of the four borders. It can have from one to four colors.

Set the color of the right border

This example demonstrates how to set the color of the right border.

Test Yourself with Practices 

Projects