Skip to content

Instantly share code, notes, and snippets.

View PierreBtz's full-sized avatar

Pierre Beitz PierreBtz

View GitHub Profile
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
[alias]
ci = commit
st = status
co = checkout
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@PierreBtz
PierreBtz / pod.yaml
Created February 5, 2020 13:43
dummy pod
kind: Pod
apiVersion: v1
metadata:
name: dummy-pod
namespace: dummy
spec:
containers:
- name: dummy
image: ubuntu
command: ["/bin/bash", "-ec", "while :; do echo '.'; sleep 5 ; done"]
#!/bin/sh
#
# show time machine logs
# -f = follow
PRED='subsystem == "com.apple.TimeMachine" AND processImagePath CONTAINS "backupd"'
if [ $# -gt 0 ]; then
log stream --style syslog --predicate "$PRED" --info
else
import java.util.concurrent.TimeUnit
def uptimeExtension = Jenkins.instance.getExtensionList(jenkins.model.Uptime).get(jenkins.model.Uptime)
def uptime = uptimeExtension.uptime
def startTime = uptimeExtension.startTime
def days, hours, minutes
TimeUnit.MILLISECONDS.with {
days = toDays(uptime)
hours = toHours(uptime) % 24
@PierreBtz
PierreBtz / commands.sh
Created December 7, 2016 14:03
Docker useful commands
#remove all exited containers
docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs docker rm
@PierreBtz
PierreBtz / Dockerfile
Last active November 17, 2016 21:15
Pipeline bug
FROM jenkinsci/jenkins:2.30
MAINTAINER Pierre Beitz <[email protected]>
USER root
RUN apt-get update && \
apt-get install -y docker.io && \
rm -rf /var/lib/apt/lists/* && \
usermod -a -G staff jenkins && \
echo 2.31 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state && \
private static <T extends Enum<T>, U extends Enum<U>> T fromTypeEnumToTypeEnum(U originValue, Class<T> destinationEnumClass) {
for(final T t : destinationEnumClass.getEnumConstants()) {
if(t.name().equals(originValue.name())) {
return t;
}
}
throw new UnsupportedOperationException("Translation was not implemented for " + originValue);
}
public static <T> void trim(List<T> list, int newSize) {
Preconditions.checkArgument(newSize >= 0, "Cannot trim the provided list to a negative size");
int size = list.size();
list.subList(Math.min(newSize, size), size).clear();
}