Skip to content

Instantly share code, notes, and snippets.

View merqlove's full-sized avatar

Alexander Merkulov merqlove

View GitHub Profile
@merqlove
merqlove / NavbarCtrl.coffee
Last active August 29, 2015 14:05
Angular Scope Share in module
angular.module('vc.controllers', ['vc.scopes'])
.controller 'NavbarController', ['$scope', '$location', 'NavbarScope', ($scope, $location, NavbarScope) ->
$scope.breadcrumbsMenu = NavbarScope.data.breadcrumbs
$scope.$on 'navbarScopeUpdated', () ->
$scope.breadcrumbsMenu = NavbarScope.data.breadcrumbs
@merqlove
merqlove / angular-animate-mock.coffee
Created August 29, 2014 11:40
NgAnimate Mock in CoffeeScript
# Converted JS from http://mgcrea.github.io/angular-strap
angular.module('ngAnimate', [])
.factory('$$animateReflow', ['$window', '$timeout', ($window, $timeout) ->
requestAnimationFrame = $window.requestAnimationFrame ||
$window.webkitRequestAnimationFrame ||
(fn) ->
$timeout(fn, 10, false)
@merqlove
merqlove / DataBagService.coffee
Last active August 29, 2015 14:05
AngularJS service to work with Chef DataBags via Knife CLI.
'use strict';
class DataBagService
_exec = {}
_tmp = {}
_fs = {}
_knife = ''
constructor: (@$q) ->
console.log 'DataBagService: constructor called'
@merqlove
merqlove / routes.coffee
Created August 18, 2014 06:54
Global Resolve for Angular ngRoute
'use strict';
angular.module('app.routes')
.config(['$routeProvider', ($routeProvider) ->
angular.extend({}, $routeProvider, {
orgWhen: (path, route) ->
route.resolve ||= {}
route.resolve = _.merge(route.resolve, {
chef: 'OrganizationCheckerProvider'
@merqlove
merqlove / OrganizationsRoute.coffee
Last active August 29, 2015 14:05
Angular NgRoute UrlFor helper via Directive
'use strict';
angular.module('app.routes', ['ngRoute', 'app.config'])
.config(['$routeProvider', 'ROUTES', ($routeProvider, ROUTES) ->
$routeProvider
# Organizations
.when(ROUTES.organizations, {
templateUrl: '/templates/organizations/index.html',
describe('e2e: main', function() {
var ptor;
beforeEach(function() {
browser.get('/');
ptor = protractor.getInstance();
});
it('should load the home page', function() {
# Karma configuration
# Generated on Tue Aug 20 2013 16:26:25 GMT-0400 (EDT)
module.exports = (config) ->
config.set
# base path, that will be used to resolve all patterns, eg. files, exclude
basePath: '..'
# frameworks to use
@merqlove
merqlove / create_rails_api_request.coffee
Last active August 29, 2015 14:02
Angular $resource experience with Rails based API
# Create service for our factories. Don't blow .json extension. This is easiest path to get JSON request in AUTO mode.
angular.module("identityService", ["ngResource"])
.factory 'Identity', ($resource) ->
$resource '/api/v1/identities/:id.json',
{ id:'@id' }
# Added update via PUT
@identities.config ($resourceProvider) ->
$resourceProvider.defaults.actions.update = { method: 'PUT' }
@merqlove
merqlove / routes.rb
Created June 6, 2014 20:07
Spree routing share across engines and app.
module Spree
module Core
class Engine < ::Rails::Engine
def self.add_routes(&block)
@spree_routes ||= []
# Anything that causes the application's routes to be reloaded,
# will cause this method to be called more than once
# i.e. https://github.com/plataformatec/devise/blob/31971e69e6a1bcf6c7f01eaaa44f227c4af5d4d2/lib/devise/rails.rb#L14
# In the case of Devise, this *only* happens in the production env
@merqlove
merqlove / spree.js.coffee.erb
Created June 6, 2014 20:04
Rails engine JS assets route path fix from Spree
#= require jsuri
class window.Spree
@ready: (callback) ->
jQuery(document).ready(callback)
@mountedAt: ->
"<%= Rails.application.routes.url_helpers.spree_path %>"
@pathFor: (path) ->
"#{window.location.origin}#{@mountedAt()}#{path}"