Skip to content

Instantly share code, notes, and snippets.

@cladera
cladera / karma-conf.js
Last active April 30, 2020 00:59
AngularJs: Testing directive with templateUrl
// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2015-06-05 using
// generator-karma 0.9.0
module.exports = function(config) {
'use strict';
config.set({
// enable / disable watching file and executing tests whenever any file changes
@cladera
cladera / restart_bluetooth.sh
Created January 27, 2016 08:50 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@cladera
cladera / product.html
Last active August 29, 2015 14:15
Google Analytics Experiments in AngularJS - product.html
<div>
<h1>{{product.name}}</h1>
<p>{{product.price}}</p>
<img ng-src="{{product.picture}}">
<p>{{product.description}}</p>
<div>
<button ng-if="variant === 'v0'" class="red-button" ng-click="addToCart()">Add to cart</button>
<button ng-if="variant === 'v1'" class="green-button" ng-click="addToCart()">Add to cart</button>
</div>
</div>
@cladera
cladera / list.html
Created February 16, 2015 12:22
Google Analytics Experiments in AngularJS - list.html
<div>
<ul class="list">
<li ng-repeat="product in products">
<a ng-href="#/product/{{product.id}}">{{product.name}} - {{product.price}}</a>
</li>
</ul>
</div>
@cladera
cladera / productcontroller.js
Last active August 29, 2015 14:15
Google Analytics Experiments in AngularJS - productcontroller.js
'use strict';
angular.module('myStoreApp')
.controller('ProductController', ['$scope', '$routeParams','$http', '$window', function($scope, $routeParams, $http, $window){
$scope.variant = $window.variant;
$http.get('api.mystore.com/products/'+$routeParams.id)
.success(function(product){
$scope.product = product;
@cladera
cladera / listcontroller.js
Created February 16, 2015 12:21
Google Analytics Experiments in AngularJS - listcontroller.js
'use strict';
angular.module('myStoreApp')
.controller('ListController', ['$scope', '$http', function($scope, $http){
$http.get('api.mystore.com/products/')
.success(function(products){
$socpe.products = products;
});
}]);
@cladera
cladera / app.js
Last active August 29, 2015 14:15
Google Analytics Experiments in AngularJS - app.js
'use strict';
angular.module('myStoreApp', [
'ngRoute'
])
.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'list.html',
controller: 'ListController'
@cladera
cladera / index.html
Last active August 29, 2015 14:15
Google Analytics Experiments in AngularJS - index.html
<html ng-app="myStoreApp">
<head>
<title>My products store</title>
<script src="//www.google-analytics.com/cx/api.js?experiment=EXPERIMENT_ID"></script>
<script>
var variant = cxApi.chooseVariation();
if(cxApi.getChosenVariation() !== cxApi.NO_CHOSEN_VARIATION){
window.variant = 'v'+variant;
}
</script>
@cladera
cladera / url_tag_replace.js
Created August 22, 2014 07:44
URL Tag replace
/* User data sample */
var user = {
uid: 5678,
email: 'marc@vancast.net'
};
/* Tag separator: *| */
/* g modiffier is mandatory */
var pattern = /\*\|([a-zA-Z0-9_]+)\|\*/g;
var url = 'http://www.acme.com/tnt/buy/?user=*|UID|*&email=*|EMAIL|*&size=*|SIZE|*';