Skip to content

Instantly share code, notes, and snippets.

View mgonto's full-sized avatar

Martin Gontovnikas mgonto

View GitHub Profile
@mgonto
mgonto / modelservice.js
Created May 1, 2013 18:11
Model Service
angular.module("test").service("Greeting", function() {
this.greet = null;
this.greetTo = function(name) {
this.greet = "Hello " + name;
}
});
angular.module("test").controller("TestCtrl", function(Greeting) {
$scope.greeting = Greeting;
@mgonto
mgonto / keybase.md
Created April 7, 2016 01:29
keybase.md

Keybase proof

I hereby claim:

  • I am mgonto on github.
  • I am mgonto (https://keybase.io/mgonto) on keybase.
  • I have a public key whose fingerprint is 1316 6AE9 2A45 7160 296C DC12 7620 77C0 02B8 68CF

To claim this, I am signing this object:

@mgonto
mgonto / one.scala
Created November 12, 2013 00:31
Scala Reactive
def heapList(heap: H): List[A] = {
if (isEmpty(heap)) {
Nil
} else {
findMin(heap) :: heapList(deleteMin(heap))
}
}
property("Added and removed elements") = forAll { (h: H, values: List[A]) =>
val listOfElemsBefore = heapList(h)
@mgonto
mgonto / event.js
Created June 4, 2013 02:33
Angularytics Track event with service
angular.controller('MainCtrl', function(Angularytics, $scope) {
$scope.click = function() {
Angularytics.trackEvent("Home Category", "Button clicked");
}
});
@mgonto
mgonto / app.js
Last active December 18, 2015 01:19
Angularytics Bootstrap
angular.module('sample-app', ['angularytics'])
.config(function(AngularyticsProvider) {
AngularyticsProvider.setEventHandlers(['Console', 'Google']);
})
.run(function(Angularytics) {
Angularytics.init();
});
@mgonto
mgonto / track.html
Last active December 18, 2015 01:19
Angularytics Track Event filter
<label>Click here to submit buddy</label>
<input type="submit"
ng-click="doSomething() | trackEvent:'Home Category':'Button clicked'" />
@mgonto
mgonto / restangular.js
Created May 24, 2013 21:32
Restangular impl
// Assigning promise
// GET /api/v1/users
var users = Restangular.all('users').getList();
// GET /api/v1/users/123
var user = Restangular.one('users',123).get();
// Assigning value
// GET /api/v1/users
Restangular.all('users').getList().success(function(users) {
@mgonto
mgonto / resource.js
Created May 24, 2013 21:27
$resource impl
var userResource = $resource('/users/:userId', {}, {
getList: {method: 'GET', params: {}, isArray: true},
get: {method: 'GET', params: {}, isArray: false},
});
var users = userResource.getList();
var user = userResource.get({userId: 123})
// Later in the code
var carResource = $resource('/users/:userId/cars/:carId', {}, {
@mgonto
mgonto / directive.js
Created May 19, 2013 02:01
directive proposed
module.directive('pie', function () {
return {
replace: true,
restrict: 'EA',
scope: {type: '@', data:'='},
templateUrl: "/js/test/angular/partials/pie.html",
controller: ['$scope', '$routeParams', '$element', '$filter', function($scope, $routeParams, $element, $filter) {
$scope.$watch('data', function() {
if (_.isUndefined($scope.data) || _.isNull($scope.data) || $filter('isZeroData')($scope.data)) {
@mgonto
mgonto / firstTab.html
Created May 19, 2013 02:00
firstTab.html
<div>
<h1>First Tab</h1>
<input type="text" ng-model="query.searchText" />
<pie data="data.valuesData | forPie" type="valuesPie" />
</div>