Skip to content

Instantly share code, notes, and snippets.

View judoole's full-sized avatar

Ole Christian Langfjæran judoole

View GitHub Profile
@judoole
judoole / cucumber-scala-dependency-injection.gradle
Last active August 29, 2015 14:16
Scala Cucumber does not support dependency injection. https://github.com/cucumber/cucumber-jvm/issues/469 A workaround is to use Java or Groovy. This setup worked for me.
dependencies {
testCompile "junit:junit-dep:4.11"
testCompile "info.cukes:cucumber-scala_2.10:1.2.2"//TODO: Can be deleted?
testCompile "info.cukes:cucumber-core:1.2.2"
testCompile 'info.cukes:cucumber-java:1.2.2'
testCompile "info.cukes:cucumber-junit:1.2.2" //TODO: Not needed?
//If you'd like some dependencies
testCompile 'info.cukes:cucumber-spring:1.2.2'
testCompile 'org.springframework:spring-test:4.0.5.RELEASE'
@judoole
judoole / jira_issues_since_last_tag.sh
Created April 13, 2015 11:41
Find unique Jira issues since last tag. Assumes logs related to Jira task starts with jira id.
git log `git describe --tags --abbrev=0`..HEAD --format=%s | grep -o "^\w*-\d*" | sort | uniq
@judoole
judoole / docker-compose.yml
Created August 19, 2015 19:52
Docker compose + Slack
hubot:
build: .
restart: always
links:
- redis:redis
environment:
HUBOT_SLACK_TOKEN: <magic-token-here>
data:
image: redis
command: /bin/true
@judoole
judoole / update-minor.groovy
Last active November 30, 2015 11:35
Update minor version of a Pipeline
//http://javadoc.jenkins-ci.org/
/*
* Script for upping the minor version of the starting job, named ARTIFACT_PROJECT
* We expect every version to arrive here following this version strategy: major.minor
*/
import hudson.model.*
import jenkins.model.Jenkins
//Get the parameters
def originalVersion = build.buildVariableResolver.resolve("VERSION")
@judoole
judoole / Unmarshal.scala
Last active October 6, 2015 09:12
Unmarshal a jax ws response to object
//Using Spring to create a reader. Should be easy to write this yourself.
//file is the xml response you got stripped of SoapEnvelope and SoapBody.
def classpathResource: ClassPathResource = new ClassPathResource(file)
def inputStream: InputStream = classpathResource.getInputStream()
def xmlInputFactory: XMLInputFactory = XMLInputFactory.newInstance()
def xmlReader: XMLStreamReader = xmlInputFactory.createXMLStreamReader(inputStream)
//ObjectFactory you can find in your jax ws generated code
val instance: JAXBContext = JAXBContext.newInstance(classOf[ObjectFactory])
val unmarshaller: Unmarshaller = instance.createUnmarshaller()
@judoole
judoole / fabfile.py
Last active November 25, 2015 07:06
Fabric whoami
from fabric.api import run
def whoami():
run('whoami')
@judoole
judoole / .gitignore
Created April 14, 2016 07:23
gitignore IntelliJ share runConfigurations
.idea/*
!.idea/runConfigurations/
@judoole
judoole / failing_operator.py
Last active November 9, 2020 08:34
Blogpost on OpsGenie alerting in Airflow https://medium.com/p/239ddea61d0a
task_that_failes = BashOperator(
task_id="task_that_failes",
bash_command="this-will-fail",
on_failure_callback=OpsGenieExceptionReporter(),
)
@judoole
judoole / opsgenie_reporter_simple.py
Last active November 9, 2020 10:45
Blogpost on OpsGenie alerting in Airflow https://medium.com/p/239ddea61d0a
class OpsGenieExceptionReporter():
def __init__(self, connection_id: str = opsgenie_default,) -> None:
self.connection_id = connection_id
def __call__(self, context) -> requests.Response:
ti: TaskInstance = context["ti"]
json = {
"message": f"Something went terribly wrong with {ti.task_id}",
"description": f"See more at {ti.log_url}",
"responders": [{"name": "my-fancy-team", "type": "team"}],
@judoole
judoole / opsgenie_closer.py
Last active November 9, 2020 10:48
Blogpost on OpsGenie alerting in Airflow https://medium.com/p/239ddea61d0a
class OpsGenieCloseHandler():
def __init__(self, connection_id: str = "opsgenie_default",) -> None:
self.connection_id = connection_id
def __call__(self, context) -> requests.Response:
task_instance: TaskInstance = context['task_instance']
if task_instance.try_number > 1:
# create the alias
alias = f"{ti.dag_id}.{ti.task_id}-{context['ds']}"