Set div at center of the screen CSS.

If you know the dimensions of div.

.centered {
  position: fixed;  /*IE6 position:absolute */
  top: 50%;
  left: 50%;
  margin-top: -50px; /* Half of the Height of div*/
  margin-left: -100px; /* Half of the Width of div*/
}

If you Don't know the dimensions of div.

.centered {
  position: fixed; /*IE6 position:absolute */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

System.LimitException: DML currently not allowed


System.LimitException: DML currently not allowed VisualForce.


This Error because of allowDML is false for VisulaForce Component.

Resolution: Set allowDML="true" in component. 

Difference between angular.copy() and assignment (=).

$cope.context = 'some text';
$scope.master = context;
Thus in the later case, if you we're to change something in $scope.master you would also change context.
But in $scope.master = angular.copy($scope.context);
 angular.copy() performs a deep copy of the argument - essentially creating a new object - whereas using the assignment operator = just assigns reference's.
For more details on angular.copy visit Here.
     

Methods defined as TestMethod do not support Web service callouts Stack Trace: null


This error occurs because webService callouts is not allowed in Test class.

To bypass callouts add HttpcalloutMock class.



Here is Sample test class with mock class to bypass webservice Callout.

**********************  Test Class ***************************

@isTest 
private class Test_class {

    private class RestMock implements HttpCalloutMock {
        
        public HTTPResponse respond(HTTPRequest req) {
            String fullJson = 'your Json Response';
            
            HTTPResponse res = new HTTPResponse();
            res.setHeader('Content-Type', 'text/json');
            res.setBody(fullJson);
            res.setStatusCode(200);
            return res;
        }
    }
    static testMethod void service_call() {
        
        Test.setMock(HttpCalloutMock.class, new RestMock());
        Test.startTest();

        //your webserive call code

        Test.StopTest();


    }
}



Mock class will take care webservice callouts.





How To Call Function after ng-repeat get Load ?



<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
 <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
<script>
               var App = angular.module('myApp', ['ui.bootstrap']);
                App.directive("repeatEnd", function(){
                    return {
                        restrict: "A",
                        link: function (scope, element, attrs) {
                            if (scope.$last) {
                                scope.$eval(attrs.repeatEnd);
                            }
                        }
                    };
                });

           App.controller('myctrl',['$scope',function($scope)
            {

                     $scope.names = '["test","Tst2"]';
                      var onEnd = function(){
                             console.log('load is complete');
                      };

            }]);
</script>

<body ng-app="myApp" class="container" ng-controller="myctrl" id="LineSite">
        <div ng-repeat="name in names" repeat-end="onEnd()"/>
</body>


Creating new document from image base64 text

Creating new document from image base64 text


        blob fileContent = EncodingUtil.base64Decode(fileData); //fileData is base64 data of image. 
  Attachment a = new Attachment(parentId = parentId); // parentId : Id of record.
  a.body = fileContent;
  a.name = 'ImageName.png';
  insert a;

Avoid Recursive Trigger

public Class checkRecursive{
    private static boolean run = true;
    public static boolean runOnce(){
    if(run){
     run=false;
     return true;
    }else{
        return run;
    }
    }
}