Skip to content

Instantly share code, notes, and snippets.

@frode-carlsen
frode-carlsen / sed-replace-multiple-key-value
Created January 20, 2020 09:59
Sed replace list of key values from file into another
sed -r "$(sed -e 's|\([^=]*\)=\(.*\)|''s\|\1\|\2\|g;''|g; ' input-patterns.txt | grep -v -E '(^$)|#' | tr '\n' ' ')" <input-file.yaml >new-file.yaml
@frode-carlsen
frode-carlsen / Git - fatfiles
Last active April 5, 2018 06:52
Git memorable commands
# from https://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big
# Find large files and eradicate
git rev-list --all --objects | \
sed -n $(git rev-list --objects --all | \
cut -f1 -d' ' | \
git cat-file --batch-check | \
grep blob | \
sort -n -k 3 | \
tail -n40 | \
# Bash function to only build modules (and dependent modules) in a multi-module reactor which have been touched since current branch was forked.
function mvnd {
# NB! ignores changes in pom modules
# NB! checks only diffs branch from local master
find . -maxdepth 4 -name pom.xml | xargs -I{} grep -iL -F "<packaging>pom</packaging>" {} | xargs dirname |grep -v target | sed -e 's/^.[/]*//g' | grep . > /tmp/mvn-modules.txt && git diff --name-only master | grep -o -F -f /tmp/mvn-modules.txt | xargs | tr ' ' ',' | xargs -I{} mvn $@ -pl {}
}
function mvndu {
# NB! diffs from upstream head (can be used on master branch)
/*
Copyright (c) 2015 Frode Carlsen
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
@frode-carlsen
frode-carlsen / JmxOverSshConfigurator
Last active August 29, 2015 14:22
Configure JMX over SSH instead of SSL
/*
* Copyright (C) 2015 Frode Carlsen.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@frode-carlsen
frode-carlsen / gist:7655407
Last active December 29, 2015 10:09
Code to break up oracle sql scripts into statements that can be run via jdbc. Handles normal sql (;) endings and plsql endings (END;---comment\n/) Strips off multi-line and single-line comments, and comments embedded in sql lines. Handles different variations of package declarations, functions (which can be both plsql and sql ended), triggers, p…
package fc.db.oracle;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
@frode-carlsen
frode-carlsen / gist:7614627
Last active December 23, 2022 12:30
A very simple http server based on just J2SE + Servlet Api for unit testing. Doesn't support anything beyond what I need just now. No dependencies, fast start/stop, absolutely no gold-plating
/**
* Copyright (c) 2013 Frode Carlsen.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the <organization>. The name of the