Skip to content

Instantly share code, notes, and snippets.

View benheymink's full-sized avatar

Ben Heymink benheymink

View GitHub Profile
@benheymink
benheymink / testSpec3
Last active August 29, 2015 14:13
Fixed test spec
it('Should display the right number of elements on the page', function(){
// myExpectedObjects is an array of items i'm expecting to be
// drawn on the page
var allPromises = myExpectedObjects.map(function(myObject){
return element(by.id(myObject.id)).isPresent();
});
// Wait until all locators have been executed
protractor.promise.all(allPromises).then(function(presentValues){
for(var i = 0; i < presentValues.length; i++){
@benheymink
benheymink / gist:994ee1ce00ae064cb4fa
Created April 1, 2015 12:17
Simple RBA directive
myApp.directive('accessControl', function (userService) {
return {
restrict: 'A',
replace: false,
scope: {
permittedRoles: '='
},
link: function (scope, element) {
var roles = userService.getUserRoles;
var matchingRoles = _.intersection(roles, scope.permittedRoles);
@benheymink
benheymink / gist:b71cda67de062148351f
Created April 1, 2015 12:23
RBA directive usage
<div class="myAdminForm" access-control permitted-roles="[101]">
...<!-- Secret admin only stuff here! -->
</div>
@benheymink
benheymink / list_instances.py
Created April 16, 2021 07:47
Simple example code for OAuth access tokens for REST calls to GCP (not tested!)
import time
import json
import jwt
import requests
import httplib2
# Project ID for this request.
project = 'development-123456'
# The name of the zone for this request.
@benheymink
benheymink / sample.java
Created April 10, 2024 09:44
docx4j pptx loading
PresentationMLPackage presentationMLPackage =
(PresentationMLPackage) OpcPackage.load(new java.io.File("src/resources/testPresentation.pptx"));
System.out.printf("Slide count: %d", presentationMLPackage.getMainPresentationPart().getSlideCount());
MainPresentationPart mdp = presentationMLPackage.getMainPresentationPart();
String notesFromSlide = mdp.getSlide(0).getNotesSlidePart().getContents().toString();
System.out.printf("Slide 1 notes: %s", notesFromSlide);