Skip to content

Instantly share code, notes, and snippets.

View johnrc's full-sized avatar

John Cragun johnrc

View GitHub Profile
@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 / PrintDependencyTree
Last active August 31, 2022 15:52
Print dependency tree for R package
## function getDependencyTree()
# Only parameter that's required is the package you want a dependency tree for
getDependencyTree <- function(pack, i = -1, depLevel = c("Depends", "Imports", "LinkingTo"), availablePackages = available.packages()) {
if(i == -1) cat(pack, "\n")
i <- i + 1
packages <- unlist(tools::package_dependencies(pack, availablePackages, which = depLevel))
for(pkg in packages) {
for(n in 0:i) {
cat(" ")
}
@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
@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://git@github.com/my_username/my_repo.git
git push --all
git push --tags
@johnrc
johnrc / remote_access.ps1
Last active April 12, 2017 14:30
Powershell commands to remote access a computer
# Get credentials for the box
$credentials = (Get-Credential)
# If above doesn't work do
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ("username", $password)
Enter-PSSession -ComputerName <computername> -Credential $credentials
# Remove an item
@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