Skip to content

Instantly share code, notes, and snippets.

@sahilsk
sahilsk / test-simple-http-data.js
Created August 3, 2019 07:17 — forked from murvinlai/test-simple-http-data.js
Socket Hang up problem - A sample to generate the problem.
/*
* This is a simple HTTP data generator for testing.
*
*/
var http = require('http');
var counter = 0;
http.createServer(function (req, res) {
var start = new Date();
@sahilsk
sahilsk / README-Template.md
Created April 29, 2019 03:26 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@sahilsk
sahilsk / kubernetes_add_service_account_kubeconfig.sh
Created April 11, 2019 09:52 — forked from innovia/kubernetes_add_service_account_kubeconfig.sh
Create a service account and generate a kubeconfig file for it - this will also set the default namespace for the user
#!/bin/bash
set -e
set -o pipefail
# Add user to k8s using service account, no RBAC (must create RBAC after this script)
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi
@sahilsk
sahilsk / sendmail.py
Created April 10, 2019 06:44 — forked from WJDigby/sendmail.py
python3 send email via gmail API
from apiclient.discovery import build
from apiclient import errors
from httplib2 import Http
from oauth2client import file, client, tools
from email.mime.text import MIMEText
from base64 import urlsafe_b64encode
SENDER = <sender>
RECIPIENT = <recipient>
@sahilsk
sahilsk / increase_pom.groovy
Created March 23, 2019 13:54 — forked from dahernan/increase_pom.groovy
Groovy XML pom manipulation
/*
Script to increase the version number of the project and remove snapshots
Using Gmaven: http://docs.codehaus.org/display/GMAVEN/Executing+Groovy+Code
Execute standalone
$ mvn groovy:execute
<plugin>
<groupId>org.codehaus.gmaven</groupId>
@sahilsk
sahilsk / app.DockerFile
Created March 6, 2019 06:41 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
@sahilsk
sahilsk / jenkins-api.md
Created February 26, 2019 11:26 — forked from justlaputa/jenkins-api.md
Jenkins Json API

jobs

jenkins_url + /api/json?tree=jobs[name,color]

builds

jenkins_url + /job/${job_name}/api/json?tree=builds[number,status,timestamp,id,result]

last build

@sahilsk
sahilsk / Jenkinsfile.groovy
Created February 21, 2019 17:27 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@sahilsk
sahilsk / create-ssh-node.sh
Created February 14, 2019 05:41 — forked from Evildethow/create-ssh-node.sh
Jenkins: Create SSH node, using bash and curl
#!/usr/bin/env bash
set -o nounset -o errexit -o pipefail
usage() {
cat <<EOM
Usage:
$(basename $0) [OPTIONS]
$(basename $0) [ -j | --jenkins-url | -n | --node-name | -s | -d | --desc | --slave-home | -e | --executors | -sh | --ssh-host | -sp | --ssh-port
| -c | --cred-id | -l | --labels | -u | --user-id | -p | --password | -h | --help ]