Skip to content

Instantly share code, notes, and snippets.

@dionysius
dionysius / 1-set-import-comment.sh
Last active January 7, 2020 18:00
Go add package import comment for go projects with modules
#!/bin/bash
# This script replaces the first package directive in each go file (with some excludes) and
# adds the canonical package path as import as a comment behind it
# e.g. `package foo // import "example.com/project/pkg/foo`
#
# While the package import comment is ignored with go modules I still liked it whenever I saw
# such comment, speeding up integration of that import into my sources or `go get`ting them
#
# I'm sure we could trim the script and save some commands, but at least it does the job :)
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* cluster0 mgmt-test kubernetes-admin@mgmt-test
cluster1 member-test kubernetes-admin@member-test
cluster2 member-test2 kubernetes-admin@member-test2
$ for c in cluster0 cluster1 cluster2; do echo "###$c:###"; helm --kube-context "$c" list; done
###cluster0:###
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
kubefed 1 Mon Aug 12 18:42:35 2019 DEPLOYED kubefed-0.1.0-rc5 kube-federation-system
$ kubectl -n kube-federation-system logs kubefed-controller-manager-57b8cdbc95-bwqvk | grep -i ServiceDNS
I0816 10:28:33.699589 1 controller.go:88] Starting ServiceDNS controller
I0816 10:28:33.700424 1 reflector.go:131] Starting reflector *v1alpha1.ServiceDNSRecord (0s) from sigs.k8s.io/kubefed/pkg/controller/servicedns/controller.go:197
I0816 10:28:33.700468 1 reflector.go:169] Listing and watching *v1alpha1.ServiceDNSRecord from sigs.k8s.io/kubefed/pkg/controller/servicedns/controller.go:197
I0816 10:28:33.701320 1 reflector.go:131] Starting reflector *v1alpha1.Domain (0s) from sigs.k8s.io/kubefed/pkg/controller/servicedns/controller.go:198
I0816 10:28:33.701518 1 reflector.go:169] Listing and watching *v1alpha1.Domain from sigs.k8s.io/kubefed/pkg/controller/servicedns/controller.go:198
I0816 10:28:33.791322 1 round_trippers.go:438] GET https://10.96.0.1:443/apis/multiclusterdns.kubefed.io/v1alpha1/servicednsrecords?limit=500&resourceVersion=0 200 OK in 90 milliseconds
I
apiVersion: v1
kind: ServiceAccount
metadata:
name: kubefed-external-dns
namespace: kube-federation-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: kubefed-external-dns
@dionysius
dionysius / commands.sh
Last active July 30, 2019 16:26
kubefed v2 federate resource only to member clusters
#I have the following contexts
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* cluster0 cluster0 cluster0
cluster1 cluster1 cluster1
cluster2 cluster2 cluster2
#Using cluster0, as there is kubefed installed
$ kubectl config use-context cluster0
Switched to context "cluster0".
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: v1.15.0
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
podSubnet: 10.244.0.0/16
apiServer:
certSANs:
- 10.20.40.89
@dionysius
dionysius / v2.0.3 vs. v3.0.1.diff
Created January 30, 2018 21:29
studentquiz access.php comparison
@@ -1,105 +1,169 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
@dionysius
dionysius / urlopener
Last active August 13, 2016 10:32
UrlOpener - Enable Linux to open Window's .url files
#!/bin/bash
cat "$@" | sed -n 's/^URL=\(.*\)$/\1/p' | while read link; do
xdg-open "$link"
done
@dionysius
dionysius / Instructions.md
Last active April 14, 2016 14:38
Fix AMPPS users and groups ids. Tested for elementaryOS freya, but should work with most ubuntu derivates.

Fix AMPPS users and groups (ampps,mysql) ids

The linux edition of ampps setups users & groups with id > 1000, but I'd like to have them < 1000 so they're considered as system users.

  • Change in /etc/group and /etc/passwd the ids of these groups to the next free numbers

/etc/group before:

[...]
___other___:x:126:dionysius
@dionysius
dionysius / Instructions.md
Last active September 13, 2022 13:16
Setup launcher icon (.desktop file) for AMPPS. Tested for elementaryOS freya, but should work with most ubuntu derivates.

Fix/Create AMPPS Launcher icon (.desktop file)

Install AMPPS with default options (at this time of writing there are no options). Expecting it is installed in /usr/local/ampps/*

Since its important to place the new files at specific locations, you need to adapt the filename as requested. All files are owned by root.

ampps_starter: place this file exactly as /usr/local/bin/ampps and make it executable

ampps_bootstrapper: