Tu Pyar Hai Kisi Aur Ka , Dil Hai Ke Manta Nahin
FOR BEGINNER GIT USAGE SOME USEFUL COMMANDS USING LINUX
WITH THE HELP OF GIT WE CAN VERY EASILY HANDLE OUR PROJECT AS WELL MAINTAIN IT VERSION CONTROL. SO HERE IS SOME USEFUL COMMANDS WHICH ARE VERY HELPFUL TO FOR US :
ONCE YOU COMPLETED YOUR WORK AFTER YOU SHOULD TRY THESE COMMANDS TO PUSH DATA ON THE SERVER.SO BACKUP WILL MAINTAIN ON THE SERVER OTHERWISE WE GET SOME PROBLEMS.
WITH IN SIMPLE 10 STEPS YOU CAN COMMIT FILES
1) First Clone the remote repo into your local system with the help of this command.
git clone @:REPOPATH
2) How to check branch .Usually it will be *master by default.
git branch
3) How to check branch path
git branch -a | grep release
*4) Create and check out in another branch
git checkout -b
5) Check Status of your current branch
git status
6) How to add/modified and deleted file in current branch
git add *
7) How to add/config user name and email
git config -global user.name "sonydaman"
git config -global user.email "sonydaman@gmail.com"
8) How to commit your stage/index with message
git commit -a -m "YOUR BRANCH MESSAGE"
*9) How to push files on remote server
git push origin :
10) Check Logs of all commits
git log
ONCE YOU COMPLETED YOUR WORK AFTER YOU SHOULD TRY THESE COMMANDS TO PUSH DATA ON THE SERVER.SO BACKUP WILL MAINTAIN ON THE SERVER OTHERWISE WE GET SOME PROBLEMS.
WITH IN SIMPLE 10 STEPS YOU CAN COMMIT FILES
1) First Clone the remote repo into your local system with the help of this command.
git clone @:REPOPATH
2) How to check branch .Usually it will be *master by default.
git branch
3) How to check branch path
git branch -a | grep release
*4) Create and check out in another branch
git checkout -b
5) Check Status of your current branch
git status
6) How to add/modified and deleted file in current branch
git add *
7) How to add/config user name and email
git config -global user.name "sonydaman"
git config -global user.email "sonydaman@gmail.com"
8) How to commit your stage/index with message
git commit -a -m "YOUR BRANCH MESSAGE"
*9) How to push files on remote server
git push origin :
10) Check Logs of all commits
git log
Rolling ball in space
WANT TO PLAY JUST
PRESS W TO JUMP
MOVE FORWARD USING ARROW KEY
-->
SonyDaman
« Created by SonyDaman and develop by Sonydaman »
ENCRYPT DECRYPT IMAGE IN BASE 64 USING JAVA SCRIPT
These days usage of mobile api generally we get image encoding in base 64 and we store in our data base directly.
While fetching some kind of issue facing like some images will be crashed and not loaded.Here is the solution for us.
1.) FIRSTLY HOW IS TO BE UPLOAD IMAGE IN TO SERVER
AND ALSO STORED AND FETCHING IN BASE64 FORMAT IN MONGO DB
Try following example using server side
Try following example using server side
fs.readFile(req.files.fileName[0].path, function(err, data) { var base64data = new Buffer(data).toString('base64'); //console.log(base64data) response.mongoDB.insertData(collection,{"image" : base64data},{}, function(result) { response.requestPage.renderPage(res,constant.fileUsageView,constant.rok, {"images" : result}) }); })
2) I am using JADE template so this code looks like this
Try following example using Try it option available at the top right corner of the below sample code box −
h2 Images
each image, i in images
img(src="data:image/jpeg;base64,#{image.image}" alt="#{image._id}")
JUST TRY IT VERY EASY TO USE ;)
CORS header 'Access-Control-Allow-Origin' missing
WHEN GETTING ERROR USING REQUEST FROM LOCAL FOLDER
USE THIS STEPS AS FOLLOWS : -
Basically, by running the following command (or creating a shortcut with it and opening Chrome through that)
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
you can open a new "unsecure" instance of Chrome at the same time as you keep your other "secure" browser instances open and working as normal.
Export HTML INTO EXCEL USING JAVASCRIPT
USING OBEJCT IN NODE JS
WORKING WITH NODE USING OOPS CONCEPTS
Class pattern
// Constructor
function Foo(bar) {
// always initialize all instance properties
this.bar = bar;
this.baz = 'baz'; // default value
}
// class methods
Foo.prototype.fooBar = function() {
};
// export the class
module.exports = Foo;
Instantiating a class is simple:
// constructor call
var object = new Foo('Hello');
Note that I recommend using function Foo() { ... }
for constructors instead ofvar Foo = function() { ... }
.
The main benefit is that you get better stack traces from Node when you use a named function. Generating a stack trace from an object with an unnamed constructor function:
var Foo = function() { };
Foo.prototype.bar = function() { console.trace(); };
var f = new Foo();
f.bar();
... produces something like this:
Trace:
at [object Object].bar (/home/m/mnt/book/code/06_oop/constructors.js:3:11)
at Object. (/home/m/mnt/book/code/06_oop/constructors.js:7:3)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
... while using a named function
function Baz() { };
Baz.prototype.bar = function() { console.trace(); };
var b = new Baz();
b.bar();
... produces a stack trace with the name of the class:
Trace:
at Baz.bar (/home/m/mnt/book/code/06_oop/constructors.js:11:11)
at Object. (/home/m/mnt/book/code/06_oop/constructors.js:15:3)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
To add private shared (among all instances of the class) variables, add them to the top level of the module:
// Private variable
var total = 0;
// Constructor
function Foo() {
// access private shared variable
total++;
};
// Expose a getter (could also expose a setter to make it a public variable)
Foo.prototype.getTotalObjects = function(){
return total;
};
function Foo() { ... }
for constructors instead ofvar Foo = function() { ... }
.Avoid assigning variables to prototypes
If you want to define a default value for a property of an instance, define it in the constructor function.
Prototypes should not have properties that are not functions, because prototype properties that are not primitives (such as arrays and objects) will not behave as one would expect, since they will use the instance that is looked up from the prototype. Example for Dimitry Sosnikov's site:
var Foo = function (name) { this.name = name; };
Foo.prototype.data = [1, 2, 3]; // setting a non-primitive property
Foo.prototype.showData = function () { console.log(this.name, this.data); };
var foo1 = new Foo("foo1");
var foo2 = new Foo("foo2");
// both instances use the same default value of data
foo1.showData(); // "foo1", [1, 2, 3]
foo2.showData(); // "foo2", [1, 2, 3]
// however, if we change the data from one instance
foo1.data.push(4);
// it mirrors on the second instance
foo1.showData(); // "foo1", [1, 2, 3, 4]
foo2.showData(); // "foo2", [1, 2, 3, 4]
- LOG "foo1" [1,2,3]
- LOG "foo2" [1,2,3]
- LOG "foo1" [1,2,3,4]
- LOG "foo2" [1,2,3,4]
Hence prototypes should only define methods, not data.
If you set the variable in the constructor, then you will get the behavior you expect:
function Foo(name) {
this.name = name;
this.data = [1, 2, 3]; // setting a non-primitive property
};
Foo.prototype.showData = function () { console.log(this.name, this.data); };
var foo1 = new Foo("foo1");
var foo2 = new Foo("foo2");
foo1.data.push(4);
foo1.showData(); // "foo1", [1, 2, 3, 4]
foo2.showData(); // "foo2", [1, 2, 3]
Don't construct by returning objects - use prototype and new
For example, construction pattern which returns an object is terrible (even thoughit was introduced in "JavaScript: The Good Parts"):
function Phone(phoneNumber) {
var that = {};
// You are constructing a custom object on every call!
that.getPhoneNumber = function() {
return phoneNumber;
};
return that;
};
// or
function Phone() {
// You are constructing a custom object on every call!
return {
getPhoneNumber: function() { ... }
};
};
Here, every time we run Phone(), a new object is created with a new property. The V8 runtime cannot optimize this case, since there is no indication that instances of Phone are a class; they look like custom objects to the engine since prototypes are not used. This leads to slower performance.
It's also broken in another way: you cannot change the prototype properties of all instances of Phone, since they do not have a common ancestor/prototype object. Prototypes exists for a reason, so use the class pattern described earlier.
MOBILE JQUERY
MAKE YOUR MOBILE TEMPLATE
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone" data-theme="a">
<div data-role="header">
<h1>Page Header</h1>
</div>
<div data-role="main" class="ui-content">
<p>Some Text..</p>
<a href="#">A Standard Text Link</a>
<a href="#" class="ui-btn">Link Button</a>
<p>A List View:</p>
<ul data-role="listview" data-autodividers="true" data-inset="true">
<li><a href="#">Adele</a></li>
<li><a href="#">Billy</a></li>
</ul>
<label for="fullname">Input Field:</label>
<input type="text" name="fullname" id="fullname" placeholder="Name..">
<label for="switch">Toggle Switch:</label>
<select name="switch" id="switch" data-role="slider">
<option value="on">On</option>
<option value="off" selected>Off</option>
</select>
</div>
<div data-role="footer">
<h1>Page Footer</h1>
</div>
</div>
Subscribe to:
Posts (Atom)
0 comments: