Skip to content

Instantly share code, notes, and snippets.

View gkhays's full-sized avatar

Garve Hays gkhays

View GitHub Profile
@gkhays
gkhays / .block
Last active May 12, 2022 13:25
Oscillating Sine Wave Rendered with JavaScript
license: cc-by-4.0
@gkhays
gkhays / JavaStringPlaceholder.md
Last active January 17, 2018 22:55
Java string formatting

String.format

String s = "hello %s!";
s = String.format(s, "world");
assertEquals(s, "hello world!"); // should be true

See String.format method.

Format String Syntax

JavaScript Snippets

When I move away from JavaScript, I forget these after a while and always have to refresh my memory.

// Enumerate the keys in an object.
function enumKeys(obj) {
  Object.keys(obj).forEach(function(key) {
    console.log(obj[key]);
 });
@gkhays
gkhays / dbdiff.sh
Last active November 28, 2017 14:26
Performs a liquibase diff and outputs a change log. In this case the databases are hosted in docker containers.
#!/bin/bash
LIQUIBASE_HOME=/usr/local/liquibase
M2_REPO=~/.m2/repository
CLASSPATH="./postgresql-9.4.1208.jar"
# Fetch the NAT-ed port information for each of the database containers.
BASE_DB_PORT=$(PORT_VAR=$(docker-compose port baselinedb 5432) ; echo ${PORT_VAR##*:})
DELTA_DB_PORT=$(PORT_VAR2=$(docker-compose port deltadb 5432) ; echo ${PORT_VAR2##*:})
@gkhays
gkhays / ReadConsoleInput.java
Created September 16, 2017 21:06
Demonstrates how to read user input from the console until a terminating character has been entered; in this case 'q'.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
public class ReadConsoleInput {
@gkhays
gkhays / bottles.pl
Last active July 11, 2017 18:44
Homomorphism? Or is is something like Onomatopoeia? In a Perl program...
#!/usr/bin/perl
use re 'eval';
''=~( '(?{' .('`' |'%') .('[' ^'-')
.('`' |'!') .('`' |',') .'"'. '\\$'
.'==' .('[' ^'+') .('`' |'/') .('['
^'+') .'||' .(';' &'=') .(';' &'=')
.';-' .'-'. '\\$' .'=;' .('[' ^'(')
.('[' ^'.') .('`' |'"') .('!' ^'+')
.'_\\{' .'(\\$' .';=('. '\\$=|' ."\|".( '`'^'.'
@gkhays
gkhays / Maven-Dependencies-View.md
Created May 3, 2017 14:58
How to place Maven dependencies in a folder (under Eclipse).
@gkhays
gkhays / README.md
Last active April 17, 2017 02:57
Scrape endurance workouts from http://crossfitcypress.com/wod/.

Scrape Endurance Workouts

Use BeautifulSoup to scrape the endurance workouts from Crossfit Cypress; http://crossfitcypress.com/wod/.

Output so far.

Python Version:
3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]
3.6.1
@gkhays
gkhays / JupyterCellInVSCode.ipynb
Last active March 15, 2017 22:27
Run Jupyter Notebook Cells in VSCode
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gkhays
gkhays / pom.xml
Created March 9, 2017 03:16 — forked from cgruber/pom.xml
Example enforcer rule to exclude commons-collections 3.2.1 from the build
<!-- Avoid the M.A.D. Gadget vulnerability in certain apache commons-collections versions -->
<project>
<!-- ... -->
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<goals><goal>enforce</goal></goals>