Skip to content

Instantly share code, notes, and snippets.

Working from home

Vikas Kumar vikas027

Working from home
  • Sydney, Australia
View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional


hayderimran7 /
Last active Jun 7, 2021
jenkins groovy get API token of a user

This is pretty simple snippet to get API Token of a user , lets say "MYUser" in jenkins.
its pretty useful when you are working with 'jenkins-job-builder' to update jobs in jenkins, and you need to get the api token which JJB needs inorder to update jobs to ..
run this code in either jenkins script console , or as i prefer, in form of init.groovy.
so when jenkins master starts, i create a user for JJb.
after that i get the token right away and pass it to my JJB jobs folder to file 'jenkins_jobs.ini' :)_ .

phrawzty /
Last active Jun 2, 2021
simple python http server to dump request headers
#!/usr/bin/env python2
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
cyrille-leclerc / pipeline.groovy
Last active Apr 8, 2021
Escape character & quotes in Jenkins Pipeline
View pipeline.groovy
docker.image('cloudbees/java-build-tools:0.0.6').inside {
sshagent(['github-ssh-credentials']) {
sh """
git version
git config --local \\"\\"
git config --local \\"Cyrille Le Clerc\\"
git clone
date &> now.txt
vitalyisaev2 /
Last active Mar 16, 2021
Script for obtaining Gitlab API Personal Access Token
Script that creates Personal Access Token for Gitlab API;
Tested with:
- Gitlab Community Edition 10.1.4
- Gitlab Enterprise Edition 12.6.2
- Gitlab Enterprise Edition 13.4.4
import sys
import requests
moertel / suppress_ruby_output.rb
Last active Feb 2, 2021
Temporarily suppress STDOUT and STDERR (ruby)
View suppress_ruby_output.rb
# Temporarily redirects STDOUT and STDERR to /dev/null
# but does print exceptions should there occur any.
# Call as:
# suppress_output { puts 'never printed' }
def suppress_output
original_stderr = $stderr.clone
original_stdout = $stdout.clone
$stderr.reopen('/dev/null', 'w'))
$stdout.reopen('/dev/null', 'w'))
superseb /
Last active Jan 26, 2021
Add custom node to Rancher 2.0 (from v2.0.0-alpha26 and up)
docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/rancher:latest
while ! curl -k https://localhost/ping; do sleep 3; done
# Login
LOGINRESPONSE=`curl -s '' -H 'content-type: application/json' --data-binary '{"username":"admin","password":"admin"}' --insecure`
LOGINTOKEN=`echo $LOGINRESPONSE | jq -r .token`
# Change password
ozbillwang /
Last active Apr 22, 2020
google cloud - account.json file for packer

The problem

The document quality of Google Cloud is far away if compare with AWS. Here is a sample.

If you met below error, when running packer or other SDK,

$ cat packer.json
  "builders": [
#!/usr/bin/env sh
docker-machine rm -f rancher host1
docker-machine create rancher --driver virtualbox --virtualbox-cpu-count "-1" --virtualbox-disk-size "8000" --virtualbox-memory "512" --virtualbox-boot2docker-url=
docker-machine scp scripts/ rancher:.
docker-machine ssh rancher sh
docker-machine regenerate-certs rancher -f
eval $(docker-machine env rancher)
docker-compose up -d
eval $(docker-machine env -u)
docker-machine create host1 --driver virtualbox --virtualbox-cpu-count "-1" --virtualbox-disk-size "54000" --virtualbox-memory "2048" --virtualbox-boot2docker-url=
miry / rbac_role_cluster.yaml
Created Mar 4, 2018
Example of roles in K8S with RBAC
View rbac_role_cluster.yaml
kind: ClusterRole
name: staging-node-user
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]