Skip to content

Instantly share code, notes, and snippets.

View CalamarBicefalo's full-sized avatar

José Carlos Valero Sánchez CalamarBicefalo

View GitHub Profile
#!/usr/bin/env bash
: '
Copyright <2017> <Tom Brand>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE S
@CalamarBicefalo
CalamarBicefalo / README.md
Created February 28, 2017 11:54 — forked from daniel-beet/README.md
Angular Testing Tips (for versions >= 2.x)

Angular Testing Examples

This is a set of examples showing ways to test when you depend on routing with components (either in the templates or component code), and want self contained routed feature modules.

TL;DR

  1. You have to use async tests, either with the async() or fakeAsync() test helpers.
package com.demo.aggregate;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.DataPolicy;
import com.gemstone.gemfire.cache.Scope;
public class GemfireAggregatesProvisioner {
private static String AGGREGATE_EVENT_QUEUE = "async-aggregate-queue";
private static String AGGREGATE_EVENT_REGION = "aggregateEvent";
@CalamarBicefalo
CalamarBicefalo / BearerAuthorizationInterceptor.kt
Created April 11, 2017 14:49
Kotlin extension methods to configure resttemplate to support various oauth2 grant types
import org.springframework.boot.web.client.RestTemplateBuilder
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpRequest
import org.springframework.http.MediaType
import org.springframework.http.client.ClientHttpRequestExecution
import org.springframework.http.client.ClientHttpRequestInterceptor
import org.springframework.http.client.ClientHttpResponse
import org.springframework.util.Assert
import org.springframework.util.Base64Utils
@CalamarBicefalo
CalamarBicefalo / OAuth2Helper.kt
Created April 11, 2017 14:57
OAuth2 MockMvc helper to retrieve valid oauth2 tokens
import org.springframework.security.authentication.TestingAuthenticationToken
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.User
import org.springframework.security.oauth2.common.OAuth2AccessToken
import org.springframework.security.oauth2.provider.ClientDetailsService
import org.springframework.security.oauth2.provider.OAuth2Authentication
import org.springframework.security.oauth2.provider.OAuth2Request
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter
import org.springframework.stereotype.Component
@CalamarBicefalo
CalamarBicefalo / Angular2AbstractPage.kt
Created April 12, 2017 15:52
Ensures Angular2 is stable before selenium continues. Uses fluentlenium
import org.fluentlenium.core.FluentPage
import org.fluentlenium.core.domain.FluentList
import org.fluentlenium.core.domain.FluentWebElement
import org.openqa.selenium.JavascriptExecutor
import org.openqa.selenium.WebDriver
import java.util.concurrent.TimeUnit
open class AbstractPage : FluentPage() {
override fun getDriver(): WebDriver {
val driver = super.getDriver()
@CalamarBicefalo
CalamarBicefalo / checkJenkinsBuild.sh
Created January 5, 2018 11:34
Script to check whether a jenkins build is broken or not
#!/bin/sh
build_info=$(curl -s http://<jenkinshost>/job/<your-job>/lastBuild/api/json --user <read-only-username>:<committable-password>)
job_status=`echo $build_info | grep "\"result\":\"SUCCESS\""`
if [ -n "$job_status" ]
then
continue;
else
while true; do
read -p "The latest build is broken or a build is already in progress. Is your commit fixing a broken build? (y or n) " yn
@CalamarBicefalo
CalamarBicefalo / in_memory_priority_queue.go
Created March 28, 2022 16:45
A simple priority queue implementation using generics and providing a simple constructor to define a comparator.
package priorityqueue
import (
"container/heap"
)
func NewPriorityQueue[T any](comparator func(*T, *T) bool) *InMemoryPriorityQueue[T] {
queue := inMemoryPriorityQueue[*T]{
Array: make(Array[*T], 0),
comparator: comparator,