Skip to content

Instantly share code, notes, and snippets.

@bman917
bman917 / gist:f61ba9f72be8e927149749e42c9e0cd5
Created November 11, 2017 08:07
Load property file into gradle script
def loadProperties() {
File credentialsFile = new File("${projectDir}", "credentials.properties");
Properties properties = new Properties();
if(credentialsFile.exists()) {
properties.load(new FileInputStream(credentialsFile));
properties.each { prop ->
project.ext.set(prop.key, prop.value)
}
} else {
@bman917
bman917 / paging.js
Created March 15, 2016 14:06
AngularJS: Paging for Spring Rest Pagable response
/*
*(function(...) {...} )(); --> This is called Immediately-Invoked Function Expression (IIFE)
*/
(function(angular) {
'use strict';
/*
* The PagingDecorator a decorate(...) method which does the following:
*
@bman917
bman917 / UserController
Created March 15, 2016 09:16
Spring MVC Get Currently Logged-in User
@RequestMapping(value = "/users/{id}", method = RequestMethod.DELETE)
public @ResponseBody boolean delete(@PathVariable(value = "id") String id) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String loggedInUser = authentication.getName();
log.info("Delete user: " + id + ", Current logged-in user: " + loggedInUser);
return true;
}
@bman917
bman917 / Angular 1.x simulate http delay
Created March 12, 2016 10:39
AngularJS: Simulate http delay by adding an http interceptor that does a timeout
module.config(function($httpProvider){
//Simulate http delay by adding an http interceptor that does a timeout
$httpProvider.interceptors.push(function($q, $timeout) {
return {
'response': function(response) {
var defer = $q.defer();
$timeout(function() {
defer.resolve(response);
}, 2300);
return defer.promise;
.content h1 {
background-color: #EBEBEB;
martin-top: 1.5em;
padding: .5em;
}
.content h2 {
margin-left: .25em;
border-bottom: 2px solid;
border-bottom-color: #EBEBEB;
}