Skip to content

Instantly share code, notes, and snippets.

View vikas027's full-sized avatar
🏠
Working from home

Vikas Kumar vikas027

🏠
Working from home
  • Sydney, Australia
View GitHub Profile
@ozbillwang
ozbillwang / packer-on-gcp.md
Last active September 5, 2023 23:03
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": [
@superseb
superseb / rancher2customnodecmd.sh
Last active October 1, 2022 13:56
Add custom node to Rancher 2.0 (from v2.0.0-alpha26 and up)
#!/bin/bash
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 'https://127.0.0.1/v3-public/localProviders/local?action=login' -H 'content-type: application/json' --data-binary '{"username":"admin","password":"admin"}' --insecure`
LOGINTOKEN=`echo $LOGINRESPONSE | jq -r .token`
# Change password
@miry
miry / rbac_role_cluster.yaml
Created March 4, 2018 08:29
Example of roles in K8S with RBAC
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: staging-node-user
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
@vitalyisaev2
vitalyisaev2 / personal_access_token.py
Last active April 19, 2024 12:53
Script for obtaining Gitlab API Personal Access Token
#!/usr/bin/python3
"""
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
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 24, 2024 18:21
Semantic Commit Messages

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

Example

@paultyng
paultyng / password.tf
Last active November 30, 2017 22:52
Terraform Random Password Module
variable "length" {
default = "20"
}
resource "random_id" "password" {
byte_length = "${var.length * 3 / 4}"
}
output "password" {
value = "${random_id.password.b64}"
#!/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=https://github.com/boot2docker/boot2docker/releases/download/v1.11.2/boot2docker.iso
docker-machine scp scripts/rancher-net.sh rancher:.
docker-machine ssh rancher sh rancher-net.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=https://github.com/boot2docker/boot2docker/releases/download/v1.11.2/boot2docker.iso
@cyrille-leclerc
cyrille-leclerc / pipeline.groovy
Last active March 9, 2022 23:41
Escape character & quotes in Jenkins Pipeline
docker.image('cloudbees/java-build-tools:0.0.6').inside {
sshagent(['github-ssh-credentials']) {
sh """
git version
git config --local user.email \\"cleclerc@cloudbees.com\\"
git config --local user.name \\"Cyrille Le Clerc\\"
git clone git@github.com:cyrille-leclerc/a-test-repo.git
date &> now.txt
@hayderimran7
hayderimran7 / get-api-token-of-user-jenkins-groovy.md
Last active June 7, 2021 14:24
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
phrawzty / 2serv.py
Last active April 24, 2024 15:02
simple python http server to dump request headers
#!/usr/bin/env python2
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):