Skip to content

Instantly share code, notes, and snippets.

View karthickvkumar's full-sized avatar
🎯
Focusing

Karthick Kumar karthickvkumar

🎯
Focusing
View GitHub Profile
@karthickvkumar
karthickvkumar / memorySizeOfObject.js
Created April 4, 2017 07:25
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
{{data.time}}
<br/>
<button ng-click="updateTime()">update time - ng-click</button>
<button id="updateTimeButton" >update time</button>
</div>
@karthickvkumar
karthickvkumar / drag.html
Created May 31, 2017 02:13
Javascript Native Drag
<div id="one">
</div>
@karthickvkumar
karthickvkumar / array_difference.js
Last active June 3, 2017 15:09
Array difference
/*Return only difference array*/
[1,2].filter(function(i){
return [3,1].indexOf(i) < 0
})
/*Return concat difference array*/
[1,2].filter(function(i){
return [3,1].indexOf(i) < 0
}).concat([3,1].filter(function(i){
return [1,2].indexOf(i) < 0
@karthickvkumar
karthickvkumar / isolate_scope.html
Last active June 5, 2017 06:35
Angular js isolated scopes
<div ng-controller="MyCtrl">
<h2>Parent Scope</h2>
<input ng-model="foo"> <i>// Update to see how parent scope interacts with component scope</i>
<br><br>
<!-- attribute-foo binds to a DOM attribute which is always
a string. That is why we are wrapping it in curly braces so
that it can be interpolated.
-->
<my-component attribute-foo="{{foo}}" binding-foo="foo"
isolated-expression-foo="updateFoo(newFoo)" >
@karthickvkumar
karthickvkumar / chunk.js
Created June 20, 2017 06:11
Chunk array into equals
Array.prototype.chunk = function ( n ) {
if ( !this.length ) {
return [];
}
return [ this.slice( 0, n ) ].concat( this.slice(n).chunk(n) );
};
//service
app.service('MyService', function () {
this.sayHello = function () {
console.log('hello');
};
});
//factory
app.factory('MyService', function () {
return {
@karthickvkumar
karthickvkumar / position.js
Created July 3, 2017 12:01
show object positoin
_transformObject: function(e) {
this.renderAll();
transform.target._renderTransformDetail(transform);
}
fabric.Object = fabric.util.createClass({});
transformDetailOffset: 30,
showTransformDetails: true,
@karthickvkumar
karthickvkumar / filter.js
Created October 5, 2017 09:53
angular filter
var left_left = $filter('filter')(objects, {
id : "LEGLEFT"
});
// Karma configuration
// Generated on Thu Oct 18 2018 18:22:53 GMT+0530 (India Standard Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
reporters: ['progress', 'html'],