Skip to content

Instantly share code, notes, and snippets.

View rajaraodv's full-sized avatar

Raja Rao DV rajaraodv

View GitHub Profile
@rajaraodv
rajaraodv / findNearBy
Last active August 29, 2015 14:05
Salesforce FindNearBy Example w/ bug fixes
<apex:page sidebar="false" showheader="false" standardController="Warehouse__c" recordSetVar="warehouses" extensions="FindNearby">
<!-- (Won't work anymore) Include in Google's Maps API via JavaScript static resource
<apex:includeScript value="{!$Resource.googleMapsAPI}" />
-->
<!-- Set this API key to fix JavaScript errors in production -->
<!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDYaP-xy0Noe1HCeNOmWE2MZYwUcehnZM0&sensor=false">
@rajaraodv
rajaraodv / gist:8c5160e105b33b841e41
Last active August 29, 2015 14:11
Upgrading to latest Git & Github tools to latest 2.2.1
--------------------------------
Check Git version:
--------------------------------
git --version
If you don't see one of the following, you should to update:
v1.8.5.6, v1.9.5, v2.0.5, v2.1.4, and v2.2.1,
@rajaraodv
rajaraodv / mochaEmailTest.js
Created December 20, 2011 22:20
Mocha test for validating emails in an array fails
require.paths.unshift('./node_modules');
require('should');
var assert = require('assert');
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, mongooseTypes = require("mongoose-types")
, db = mongoose.createConnection(getMongoUrl());
mongooseTypes.loadTypes(mongoose);
@rajaraodv
rajaraodv / error-validator-middleware
Created October 4, 2012 22:09
This example shows how to create multiple error-validator-middlewares for your Express app.
/* Say you want to add multiple validation middlewares to Express app, this is an example of how to do it.
First create 2 middlewares: first one(e.g. validateRequest1) to validate and the 2nd one to handle errors (e.g validateRequest1Handler).
If you want to add a 2nd validation middleware, create two more middlewares (validateRequest2 & validateRequest2Handler).
Note - Error-handling-middleware v/s non-error-handling-middleware
Error handler middleware must take 4 parameters(err, req, res, next) including "err" as first parameter. Where as are normal middlewares only take 3(req, res, next).
*/
//This is how it would look like..
@rajaraodv
rajaraodv / sublime-plugins
Created November 6, 2012 14:56
my sublime plugins
AdvancedNewFile
AngularJS
BracketHighlighter
DocBlockr
FileDiffs
JSFormatter
PackageControl
SideBarEnhancements
SideBarGit
Sublime-HtmlPrettify
@rajaraodv
rajaraodv / angularjsMasonryImagesLoaded1.js
Created November 24, 2012 21:17
Angularjs Masonry Before
//This is how HTML, Controller & Directive looked in my actual app at this point.
//Notice that we are applying masonry for every element as they are added by ng-repeat.
//HTML
/*
<div id="photoContainer" style="position:relative;height:800px;zoom:1;">
<div class="photo" ng-repeat="photoPost in photoPosts">
<img ng-src="{{photoPost.photo.url}}" add-masonry="photoPost"></div>
</div>
</div>
@rajaraodv
rajaraodv / gist.js
Created November 25, 2012 02:34
GistExample
function myFunction(param1) {
this.param1 = param1;
}
@rajaraodv
rajaraodv / foobardirective.js
Created November 25, 2012 05:32
foobar directive w/ imagesloaded (step2)
//Added imagesLoaded code to wait for all images to load before we apply masonry.
//But this wasn't working either! Because Angular hasn't converted ng-src="path/to/img" to src="path/to/img"
clientAppModule.directive('addMasonry', function($timeout) {
return {
restrict: 'A',
link: function(scope, element) {
scope.container.imagesLoaded(function() {
scope.container.masonry('reload');
});
}
@rajaraodv
rajaraodv / foobardirectiveFinal.js
Created November 25, 2012 05:43
foobar directive with solution
//Wrap masonry with ImagesLoaded and wrap that again with a $timeout w/ a small delay solves the issue.
clientAppModule.directive('addMasonry', function($timeout) {
return {
restrict: 'A',
link: function(scope, element) {
$timeout(function(val) { //looks like timeout or deferred solves the issue
scope.container.imagesLoaded(function() {
scope.container.masonry('reload');
});
@rajaraodv
rajaraodv / 0_reuse_code.js
Created September 18, 2016 21:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console