Skip to content

Instantly share code, notes, and snippets.

View xcoulon's full-sized avatar

Xavier Coulon xcoulon

View GitHub Profile
@xcoulon
xcoulon / nested_structs.go
Last active November 19, 2017 13:10
Nested structs in Golang (resource for the story on Medium)
type Config struct {
Server struct {
Host string `json:"host"`
Port string `json:"port"`
} `json:"server"`
Postgres struct {
Host string `json:"host"`
User string `json:"user"`
Password string `json:"password"`
DB string `json:"db"`
@xcoulon
xcoulon / client.go
Last active November 17, 2017 09:12
The benefit of using named return values in Golang
// IsEnabled queries whether or not the specified feature is enabled or not.
func (uc Client) IsEnabled(feature string, options ...FeatureOption) (enabled bool) {
defer func() {
uc.metrics.count(feature, enabled)
}()
if f == nil {
...
return false
}
@xcoulon
xcoulon / sandbox-namespace.yml
Last active November 15, 2017 09:38
Tips for Minikube and Minishift users: creating and using a custom namespace - namespace_manifest.yaml
apiVersion: v1
kind: Namespace
metadata:
name: sandbox
@xcoulon
xcoulon / config_view.yaml
Last active November 15, 2017 09:36
Tips for Minikube and Minishift users: creating and using a custom namespace - config_view.yaml
apiVersion: v1
clusters:
- cluster:
certificate-authority: /Users/xcoulon/.minikube/ca.crt
server: https://192.168.99.100:8443
name: minikube
contexts:
- context:
cluster: minikube
namespace: sandbox
OpenShift Build kitchensink-html5-mobile/pipeline-1 from https://github.com/xcoulon/kitchensink-html5-mobile.git
OpenShift Build kitchensink-html5-mobile/pipeline-1 from https://github.com/xcoulon/kitchensink-html5-mobile.git
Cloning the remote Git repository
Cloning repository https://github.com/xcoulon/kitchensink-html5-mobile.git
> git init /var/lib/jenkins/jobs/pipeline/workspace@script # timeout=10
Fetching upstream changes from https://github.com/xcoulon/kitchensink-html5-mobile.git
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress https://github.com/xcoulon/kitchensink-html5-mobile.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url https://github.com/xcoulon/kitchensink-html5-mobile.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
wget https://gist.githubusercontent.com/xcoulon/1c57f3491d577db95a58a0cc1258fc09/raw/298b65c4c8530d67f331eec69dec23dee2023855/jenkins-pipeline-template.json
oc new-project kitchensink-cli
oc new-app -f jenkins-pipeline-template.json -p PROJECT=kitchensink-cli -p SOURCE_REPOSITORY_URL=https://github.com/xcoulon/kitchensink-html5-mobile.git -l app=kitchensink-cli
{
"kind": "Template",
"apiVersion": "v1",
"metadata": {
"name": "jenkins-pipeline",
"creationTimestamp": null,
"annotations": {
"description": "This is a preview of NEXT version of Jenkins template. It is a subject of change. Use with caution.\nJenkins service, with persistent storage, pipeline, kubernetes and OpenShift Build Sync plugins.\nThe username is 'admin' and the tutorial at https://github.com/openshift/origin/blob/master/examples/jenkins/README.md contains more information about using this template.\nYou must have persistent volumes available in your cluster to use this template.",
"iconClass": "icon-jenkins",
"tags": "instant-app,jenkins"
{
"kind": "Template",
"apiVersion": "v1",
"metadata": {
"name": "pipelineproject",
"creationTimestamp": null,
"annotations": {
"description": "This example shows how to create a simple Java application in openshift origin v3",
"iconClass": "icon-jboss",
"tags": "instant-app,java,mysql"
apiVersion: v1
kind: BuildConfig
metadata:
name: pipeline
namespace: pipelineproject
selfLink: /oapi/v1/namespaces/pipelineproject/buildconfigs/pipeline
uid: a5b191c1-2db9-11e6-897a-52540039ecd4
resourceVersion: '47305'
creationTimestamp: '2016-06-08T20:43:25Z'
labels:
@xcoulon
xcoulon / logger_template.adoc
Last active July 2, 2024 17:17
SLF4J Logger Template for Eclipse

SLF4J Logger Template for Eclipse

In Preferences>Java>Editor>Templates, create a new template named logger in the Java type members context and with the following pattern:

/** The usual Logger.*/
private static final Logger LOGGER = LoggerFactory.getLogger(${enclosing_type}.class);
${:import('org.slf4j.Logger','org.slf4j.LoggerFactory')}