Skip to content

Instantly share code, notes, and snippets.

View cwilper's full-sized avatar

Chris Wilper cwilper

View GitHub Profile
@cwilper
cwilper / checkok.sh
Created July 10, 2017 15:02
Checks if a given url returns 200 ok and returns 0 if so, returns 1 (error) otherwise
#!/bin/sh
curl -Ssf "$1" > /dev/null
if [[ $? -ne 0 ]]; then
echo "Error: Non-200 returned for url $1"
exit 1
fi
@cwilper
cwilper / ImDim.java
Last active April 20, 2017 19:01
Get image size from file
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
/**
@cwilper
cwilper / TimesheetSnippet.vba
Created April 15, 2017 02:30
Excel VBA code snippets
'If G and H are defined for the given row, add the difference to K and clear them
Private Sub Update_Total(ByVal Row As Integer)
Dim punchStart, punchEnd, timeWorked As Integer
punchStart = Range("G" & Row).Value
punchEnd = Range("H" & Row).Value
timeWorked = punchEnd - punchStart
If (punchStart > 0 And punchEnd > 0 And timeWorked > 0) Then
Range("K" & Row).Value = Range("K" & Row) + timeWorked
Range("G" & Row).Value = ""
Range("H" & Row).Value = ""
@cwilper
cwilper / .tmux.conf
Last active November 23, 2020 02:47
My initial tmux config file
# Here's my initial tmux config, which works well on macOS and Linux,
# and uses screen-like and vi bindings. If using Linux, see notes about
# xclip below.
#
# If you use iTerm and homebew on a mac, you can set it up to automatically
# launch a new tmux session whenever a new terminal window opens:
#
# 1) Install tmux (e.g. via homebrew: brew install tmux)
# 2) Put this file in your home directory, named .tmux.conf
# 3) Edit your iTerm Preferences:
@cwilper
cwilper / BAx.md
Last active March 17, 2017 19:22
@cwilper
cwilper / handle.service
Created January 26, 2017 16:52
Systemd Unit file for Handle Service used by DSpace
# Systemd Unit file for Handle Service used by DSpace
#
# On hosts that use systemd, like RHEL7, this can be used to auto-start
# the handle service and provide the familiar "servicectl start|status|stop"
# commands for controlling execution.
#
# To install:
#
# 1) As dspace:
# REQUIRED:

Manual Solr Dump and Load via CSV

Solr has built-in CSV export and import facilities, which can be used to copy data from one core to another.

You can use the following process to select documents from one core and move them to another, using only the Solr Admin UI, Chrome, and curl.

Dump CSV from source core

  1. Use the Solr Admin UI's Query screen to formulate a query for the subset of documents you want to dump.
  2. Run the query and click on the link that gives you the raw query results.
@cwilper
cwilper / javascript-nerd-test.js
Created September 26, 2016 01:17
Javascript Nerd Test
#!/usr/bin/env node
"use strict";
// what does this function return?
function a()
{
return
{
i: 1
#!/bin/bash
#
# Dumps a subset of one Solr core and loads it into another one.
#
# WARNING: THIS DUMP AND LOAD IS LOSSY -- DO NOT USE IT FOR BACKUPS!
# In particular, multi-valued fields won't import in the target exactly as they were in the source.
#
# Before running, change the variables below as needed for your task.
#

Keybase proof

I hereby claim:

  • I am cwilper on github.
  • I am cwilper (https://keybase.io/cwilper) on keybase.
  • I have a public key whose fingerprint is 9316 C0C1 B5A6 2552 5568 335D 1173 084A BA6C 1222

To claim this, I am signing this object: