Skip to content

Instantly share code, notes, and snippets.

View mbranicky's full-sized avatar
🎯
Focusing

Marek Branicky mbranicky

🎯
Focusing
View GitHub Profile
@mbranicky
mbranicky / MovieDao.java
Created May 28, 2019 10:02
Movie by ID where joined comments are ordered by date in descending order
/**
* Gets a movie object from the database.
*
* @param movieId - Movie identifier string.
* @return Document object or null.
*/
public Document getMovie(String movieId) {
if (!validIdValue(movieId)) {
return null;
}
@mbranicky
mbranicky / module_basic_example.js
Last active August 29, 2015 14:28
Modules (basic examples)
var myApp = angular.module("MyApplication", ['ngRoute', 'leaflet-directive']);
myApp.configuration(...);
@mbranicky
mbranicky / cust_directive_basic_example.js
Last active September 20, 2015 12:09
Custom directive (basic example)
app.directive('appInfo', function() {
return {
restrict: 'EA', // E -element, A - attribute, C - class, M - comment
scope: {
info: '=' // attribute of this directive
},
templateUrl: 'js/directives/appInfo.html'
};
});
@mbranicky
mbranicky / service_GET_example.js
Last active August 29, 2015 14:27
Service (basic examples)
app.factory('forecast', ['$http', function($http) {
return $http.get('https://s3.amazonaws.com/codecademy-content/courses/ltp4/forecast-api/forecast.json')
.success(function(data) {
return data;
})
.error(function(err) {
return err;
});
}]);
@mbranicky
mbranicky / controller_basic_example.js
Last active August 29, 2015 14:27
Controller (basic examples)
// 'books' is a service for fetching data about books
app.controller('ChapterController', ['$scope', 'books', '$routeParams', function($scope, books, $routeParams) {
books.success(function(data) {
$scope.book = data[$routeParams.bookId];
$scope.chapter = $scope.book.chapters[$routeParams.chapterId];
// If there no more chapters left, go back to the bookshelf view
if($routeParams.chapterId >= $scope.book.chapters.length - 1) {
$scope.nextChapterIndex = "#";
}
@mbranicky
mbranicky / routing_basic_example.js
Last active August 29, 2015 14:27
Routing (basic examples)
var app = angular.module('GalleryApp', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
controller: 'HomeController',
templateUrl: 'views/home.html'
})
.when('/photos/:id', {
controller: 'PhotoController',
templateUrl: 'views/photo.html'