Skip to content

Instantly share code, notes, and snippets.

View johnrc's full-sized avatar

John Cragun johnrc

View GitHub Profile
@johnrc
johnrc / export-cassandra.sh
Created March 30, 2020 23:06
Simple script to export Cassandra table to csv file
#!/bin/bash
table=$1
filename=$2
cqlsh -e "COPY $table TO './$filename' WITH HEADER = true;"
@johnrc
johnrc / main.go
Created March 30, 2020 23:05
Print pdf from website with Golang
func ExamplePrintToPDF() {
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
var buf []byte
if err := chromedp.Run(ctx,
chromedp.Navigate(`https://godoc.org/github.com/chromedp/chromedp`),
chromedp.ActionFunc(func(ctx context.Context) error {
var err error
buf, _, err = page.PrintToPDF().
@johnrc
johnrc / jenkins-merge-pr.sh
Created June 19, 2017 17:02 — forked from oleg-nenashev/jenkins-merge-pr.sh
Simple git merge with squash for Jenkins repos
#!/bin/bash -ex
REPO_NAME=${PWD##*/}
TARGET_ORG="jenkinsci"
#TODO: fetch from GitHib API
#TODO: if no, process parameters correctly
GITHUB_PR_NUMBER=${1}
FROM_USER=${2}
BRANCH=${3}
@johnrc
johnrc / statuses.md
Created May 15, 2017 17:12 — forked from vkostyukov/statuses.md
HTTP status codes used by world-famous APIs
API Status Codes
[Twitter][tw] 200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504
[Stripe][stripe] 200, 400, 401, 402, 404, 429, 500, 502, 503, 504
[Github][gh] 200, 400, 422, 301, 302, 304, 307, 401, 403
[Pagerduty][pd] 200, 201, 204, 400, 401, 403, 404, 408, 500
[NewRelic Plugins][nr] 200, 400, 403, 404, 405, 413, 500, 502, 503, 503
[Etsy][etsy] 200, 201, 400, 403, 404, 500, 503
[Dropbox][db] 200, 400, 401, 403, 404, 405, 429, 503, 507
@johnrc
johnrc / svn2git.md
Created April 14, 2017 09:38
Subversion to Git commands

Below is a list of helpful commands to run a successful migration of Subversion to Git.

svn log --quiet https://svn-server.example.com/repos/my_repo | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/ //g' | sort | uniq > svnauthors.txt
# convert the `svnauthors.txt` to proper format (name, email) in `authors.txt`
git svn clone --prefix="" --authors-file="authors.txt" -s https://svn-server.example.com/repos/my_repo
java -Dfile.encoding=utf-8 -jar ~/svn-migration-scripts.jar clean-git --force
git remote add origin ssh://[email protected]/my_username/my_repo.git
git push --all
git push --tags
@johnrc
johnrc / selenium-grid-docker.md
Created February 27, 2017 04:32
How to use Selenium grid via Docker

Selenium Grid on Docker

Setup Containers

docker run -d -P --name selenium-hub selenium/hub
docker run -d --link selenium-hub:hub selenium/node-chrome
docker exec -it ad6211909835 bash
@johnrc
johnrc / jenkins-git-backup.sh
Created February 13, 2017 17:05 — forked from abayer/jenkins-git-backup.sh
Example of a script for backing up Jenkins config in git.
#!/bin/bash
#
# Copies certain kinds of known files and directories from a given Jenkins master directory
# into a git repo, removing any old ones, adds 'em, commits 'em, pushes 'em.
#
set -ex
if [ $# -ne 2 ]; then
echo usage: $0 root_dir jenkins_master
@johnrc
johnrc / repset_mongo.sh
Created July 19, 2016 14:02 — forked from massenz/repset_mongo.sh
Creates and initializes a MongoDb replica set: allows the user to choose the number of members and the starting port number; this should also work on a remote host, but I have only tested it so far on localhost
#!/bin/bash
#
# Starts up a MongoDB replica set
#
# There is a lot of documentation about replica sets:
#
# http://docs.mongodb.org/manual/reference/replica-configuration/
# http://docs.mongodb.org/manual/administration/replica-sets/
#
# To read data from a SECONDARY, when in the client, use:
@johnrc
johnrc / nexus.service
Created June 25, 2016 02:44
Nexus unit file for systemd (as opposed to upstart)
[Unit]
Description=Sonatype Nexus
After=centrifydc.service
Requires=centrifydc.service
[Service]
User=user
Group=group
Type=forking
PIDFile=/path/to/nexus-2.11.4-01-bundle/nexus-2.11.4-01/bin/jsw/linux-x86-64/nexus.pid
@johnrc
johnrc / jupyterhub-install.sh
Last active May 27, 2020 00:39
JupyterHub setup on centos
#!/bin/sh
curl -O http://repo.continuum.io/archive/Anaconda3-4.0.0-Linux-x86_64.sh
chmod u+x Anaconda3-4.0.0-Linux-x86_64.sh
./Anaconda3-4.0.0-Linux-x86_64.sh -b -p /opt/anaconda3
export PATH=/opt/anaconda3/bin:$PATH
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
yum install nodejs -y
npm install -g configurable-http-proxy
pip install jupyterhub