Sunday, 30 December 2018

Web component: j-MobileCarousel

j-MobileCarousel

Works only with Bootstrap grid system and in mobile devices xs.
Configuration:
  • count {Number} count visible items (default: 1)
  • selector {String} jQuery selector (default: .col-sm-4)
  • margin {Number} left margin between items (default: 15)
  • snapping {Boolean} allows snapping (default: true)
  • animate {Number} animation timeout, 0 disables animation (default: 5000)
</> HTML

<style>
.m { margin-bottom: 20px; }
.bg { padding: 10px; background-color: #F0F0F0; }
</style>

<div data-jc="mobilecarousel__null__selector:.col-sm-3">
<div class="row">
<div class="col-sm-3 m">
<div class="bg">
<h2>Title 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, dolores.</p>
</div>
</div>
<div class="col-sm-3 m">
<div class="bg">
<h2>Title 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, dolores.</p>
</div>
</div>
<div class="col-sm-3 m">
<div class="bg">
<h2>Title 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, dolores.</p>
</div>
</div>
<div class="col-sm-3 m">
<div class="bg">
<h2>Title 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, dolores.</p>
</div>
</div>
<div class="col-sm-3 m">
<div class="bg">
<h2>Title 5</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, dolores.</p>
</div>
</div>
<div class="col-sm-3 m">
<div class="bg">
<h2>Title 6</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, dolores.</p>
</div>
</div>
<div class="col-sm-3 m">
<div class="bg">
<h2>Title 7</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Blanditiis, dolores.</p>
</div>
</div>
</div>
</div>
-----------------------------------------------------------------------------------------------------
</>  JS

COMPONENT('mobilecarousel', 'count:1;selector:.col-sm-4;margin:15;snapping:true;animate:5000', function(self, config) {

var width = 0;
var count = 0;
var index = 0;
var increment = 1;
var skip = false;
var move = false;
var anim;
var container;
var old;

self.readonly();
self.blind();

self.make = function() {
self.element.wrapInner('<div class="ui-mobilecarousel-container"><div class="ui-mobilecarousel-body"></div></div>');
$(window).on('resize', self.resize);
setTimeout(self.resize, 50);
setTimeout(self.resize, 500);
setTimeout(self.resize, 2000);
CSS('.ui-mobilecarousel .ui-mobilecarousel-{0} {1}{margin:0 0 0 {2}px;padding:0;float:left;vertical-align:top;display:inline-block}.ui-mobilecarousel .ui-mobilecarousel-{0} {1}:first-child{margin-left:0}'.format(self.id, config.selector, config.margin));
container = self.find('.ui-mobilecarousel-container').aclass('ui-mobilecarousel-' + self.id);
config.snapping && container.on('scroll', function() {
!skip && setTimeout2(self.id, self.snap, 200);
}).on('touchmove', function() {
clearTimeout(anim);
});
config.animate && (anim = setTimeout(self.animate, config.animate));
};

self.animate = function() {

if (!count || move)
return;

index += increment;

if (index === count - 1)
increment = -1;
else if (index === 0)
increment = 1;

skip = true;
anim = true;
container.animate({ scrollLeft: index * (width + config.margin) }, 200);
setTimeout(function() {
skip = false;
anim = false;
}, 400);

anim = setTimeout(self.animate, 2000);
};

self.snap = function() {
var x = container.prop('scrollLeft');
var off = Math.round(x / width);
skip = true;
move = true;
container.stop().animate({ scrollLeft: off * (width + config.margin) }, 200);
setTimeout(function() {
skip = false;
}, 500);
};

self.resize = function() {

if (WIDTH() !== 'xs') {

if (old === '1')
return;

old = '1';
count = 0;
width = 0;
self.rclass('ui-mobilecarousel');
self.css('height', '');
self.find('.ui-mobilecarousel-body').css('width', '');
self.find(config.selector).css('width', '');
return;
}

self.aclass('ui-mobilecarousel');

self.width(function(w) {

var sum = 0;
var height = 0;

width = w / config.count;
count = 0;

self.find(config.selector).each(function(index) {
var el = $(this);
sum += width + (index ? 15 : 0);
height = Math.max(el.innerHeight(), height);
el.css('width', width);
count++;
});

var k = sum + 'x' + height;
if (old === k)
return;

old = k;
self.css('height', (height >> 0) + 15);
self.find('.ui-mobilecarousel-body').css('width', sum);
});
};
});
----------------------------------------------------------------------------------
</> CSS

.ui-mobilecarousel { overflow: hidden; visibility: visible; }
.ui-mobilecarousel .ui-mobilecarousel-container { width: 100%; overflow-x: scroll; overflow-y: hidden; overflow-scrolling: touch; -webkit-overflow-scrolling: touch; }
.ui-mobilecarousel .ui-mobilecarousel-body { padding-bottom: 30px; }
.ui-mobilecarousel .row { margin: 0; }

Explain Server Side Programming

All of us would have started programming in java with the famous "hello world" program. If you can recollect, we saved the file with a '.java' extension and later compiled the program using 'javac' and then executed the program using 'java'. Apart from introducing you to the language basics, the important point is that it is a client-side program. That means you write, compile and execute the program in the client machine (i.e., your PC). No doubt, it is the easiest and fastest way to write, compile and execute the program. However, it has little practical significance when it comes to real-world programming.

Why Server Side Programming

Though it is technically feasible to implement almost any business logic using client-side programs, logically or functionally it server no purpose when it comes to enterprises application (e.g., banking, air ticketing, e-shopping, etc). To further explain, going by the client-side programming logic; a bank having 10,000customers would mean that each customer would have a copy of the program(s) in his or her PC (and now even mobiles) which translates to 10,000 programs! In addition, there are issues like security, resource pooling, concurrent access and manipulations to the database which simply cannot be handled by client-side programs. The answer to most of the issues cited above is-"Server Side Programming". Figure illustrates the Server Side Architecture in the simplest way.

Advantages of Server Side Programs

Some of the advantages of Server Side programs are as follows:
1. All programs reside in one machine called server. Any number of remote machines (called clients) can access the server programs.
ii. New functionalities to existing programs can be added at the server side which the clients can take advantage of without having to change anything.
iii. Migrating to newer versions, architectures, design patterns, adding patches, switching to new databases can be done at the server side without having to bother about client's hardware or software capabilities.
iv. Issues relating to enterprise applications like resource management, concurrency, session management, security and performance are managed by the server side applications.
v. They are portable and possess the capability to generate dynamic and user-based content (e.g., displaying transaction information of credit card or debit card depending on user's choice).

Types of Server Side Programs

The following are the different types of server side programs:
(a) Active Server Pages (ASP)
(b) Java Servlets
(c) Java Server Pages (JSP)
(d) Enterprise JavaBeans (EJB)
(e)PHP
To summarize, the objectives of server side programs are to centrally manage all programs relating to a particular application (e.g., banking, insurance, e-shopping, etc). Clients with bare minimum requirements (e.g., Pentium II, Windows XP professional, MS Internet Explorer and an internet connection) can experience the power and performance of a server (e.g., IBM Mainframe, Unix Server, etc.) from a remote location without having to compromise on security or speed. More importantly server programs are not only portable but also possess the capability to generate dynamic responses based on user's request.


Friday, 21 December 2018

Monday, 17 December 2018

Web-Development-with-MongoDB-and-NodeJS

Additional resources

For additional learning with JavaScript, I suggest you check out some of the following resources:

* Mozilla Developer Network at https://developer.mozilla.org/en-US/docs/Web/JavaScript
* Secrets of the JavaScript Ninja, John Resig, Bear Bibeault, Manning
* Learning JavaScript Design Patterns, Addy Osmani, O'Reilly
* JavaScript: The Good Parts, Douglas Crockford, O'Reilly


Sunday, 16 December 2018

The Fundamentals of Neural Networks: The basics of Perceptron 

Perceptron is a single layer neural network and a multi-layer perceptron is called Neural Networks.
https://www.tecknocracy.com/blog/5c053be06758916e3095fa61


FRONTEND DEVELOPMENT TUTORIALS

ALL THE SOFT SKILLS TUTORIALS
https://flaviocopes.com/tags/softskills/

HOW TO USE MONGODB WITH NODE.JS

IN THIS TUTORIAL I'LL SHOW YOU HOW TO INTERACT WITH A MONGODB DATABASE FROM NODE.JS


Simple File Upload with Express.js and Multer in Node.js

 A couple of years ago I wrote a blog poston how to upload a file with formidable. I had the chance to write the upload function again, and found multer to be much easier to use. Here’s another beginner example.

This example saves your file into the file system.
Read the multer documentation to do different kinds of uploads.
1. Setup

Install those modules into your Node project with

npm install --save express multer

2. Code

app. Js

const express = require('express'); const multer = require('multer'); const upload = multer({ dest: 'uploads/' // this saves your file into a directory called "uploads" }); const app = express(); app.get('/', (req, res) => { res.sendFile(__dirname + '/index.html'); }); // It's very crucial that the file name matches the name attribute in your html app.post('/', upload.single('file-to-upload'), (req, res) => { res.redirect('/'); }); app.listen(3000);


-----------


index.html


<!DOCTYPE html> <html lang="en"> <head> <title>Simple Multer Upload Example</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <form action="/" enctype="multipart/form-data" method="post"> <input type="file" name="file-to-upload"> <input type="submit" value="Upload"> </form> </body> </html>




3. Run


Go to localhost:3000 to try it out







CSS-Tricks

Glider.js https://t.co/oaV5ERJZsD
> A blazingly fast, crazy small, fully responsive, mobile-friendly, dependency free, native scrolling list with paging controls!

Awesome Deep Learning