Skip to content

Instantly share code, notes, and snippets.

@ameyms
ameyms / apply_plugin.js
Created January 26, 2015 23:03
A directive and provider pair to apply arbitrary JQuery plugins to elements
angular.module( 'ameyms.jqplugin' ).
directive( 'applyPlugin', [ 'jqueryPlugins', function ( jqPlugins ) {
var postLinkFn;
postLinkFn = function ( scope, elem, attrs ) {
var currPlugin = attrs.applyPlugin,
opts = jqueryPlugins.getOptionsFor( currPlugin );
// Apply plugin
$( elem )[ currPlugin ]( opts );
@ismaels
ismaels / polyline_decoder.js
Created September 20, 2013 12:50
Javascript function to decode google maps api polyline
// source: http://doublespringlabs.blogspot.com.br/2012/11/decoding-polylines-from-google-maps.html
function decode(encoded){
// array that holds the points
var points=[ ]
var index = 0, len = encoded.length;
var lat = 0, lng = 0;
while (index < len) {
var b, shift = 0, result = 0;
@davemo
davemo / bootstrap.js
Last active November 16, 2017 13:23
injectorsauce
(function() {
var $injector = angular.injector(['ng']);
$injector.invoke(function($http) {
// this works!
$http.get("/auth/csrf_token").then(function(response) {
angular.module("app").constant("CSRF_TOKEN", response.csrf_token);
angular.bootstrap(document, ['app']);
});