Skip to content

Instantly share code, notes, and snippets.

View tstout's full-sized avatar

Todd Stout tstout

View GitHub Profile
@tstout
tstout / MinCutLengthTest.groovy
Created November 20, 2019 22:55
testing with features #spock #groovy
package com.containerstore.project.order
import com.containerstore.store.order.services.feature.FeatureService
import spock.lang.Specification
import static com.containerstore.project.order.MinCutLength.EIGHTY_INCH_TRACK_PLATINUM
import static com.containerstore.project.order.MinCutLength.EIGHTY_INCH_TRACK_WHITE
import static com.containerstore.project.order.MinCutLength.SIXTY_INCH_STANDARD
class MinCutLengthTest extends Specification {
@tstout
tstout / space-images.sql
Last active November 19, 2019 14:12
space-images #SQL
SELECT
spc.FILE_ID
,img.IMAGE
,img.IMAGE_TYPE
,img.IMAGE_URL
,img.WALL_NAME
FROM
storeord.cpc_space spc
INNER JOIN storeord.cpc_image img
ON spc.FILE_ID = img.FILE_ID
@tstout
tstout / func.java
Last active May 15, 2020 22:52
Functional Java #java
import java.util.function.Function;
import java.util.stream.Stream;
public class Pipe {
@SafeVarargs
public final <T> Function<T, T> compose(Function<T, T>... functions) {
return Stream.of(functions)
.reduce(Function.identity(), Function::andThen);
}
@tstout
tstout / find-exclude-dirs.sh
Created August 2, 2019 19:50
recursive find ignoring directory files #bash
find . -type f | xargs -I {} grep -Hin DEPLOYMENT_ENVIRONMENT {}
# Note - the xargs usage here is OSX-specific
@tstout
tstout / delete-with-join.sql
Created July 10, 2019 20:43
delete-with-join #PLSQL
-- This is oracle-specific.
-- If using * instead of img.*, if there is a FK relationship, deletion will occur in both tables!
DELETE (SELECT
img.*
FROM
storeord.cpc_space spc
INNER JOIN storeord.cpc_image img
ON spc.FILE_ID = img.FILE_ID
WHERE
@tstout
tstout / gen_json.test.js
Created May 2, 2019 15:52
gen-eodc space documents
import { fromElfaXml } from '../elfaConverter';
import fs from 'fs';
import path from 'path';
import { intersectingStandards } from '../splitShelves';
import validator from '../../schemas/validator';
function load(file) {
return fs.readFileSync(path.resolve(__dirname, `fixtures/${file}`), {
encoding: 'utf8',
});
@tstout
tstout / genspaces.test.js
Created April 25, 2019 17:55
generate-test-spaces #javascript
import fs from 'fs';
function save(fname, document) {
fs.writeFile(
fname,
document,
function(err) {
if (err) {
return console.log(err);
}
@tstout
tstout / minimal-jest-babel.json
Created April 10, 2019 14:25
minimal jest/babel project #javascript
{
"name": "schemas2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --projects ./src --watch --testPathPattern=.test.js$"
},
"author": "",
"license": "ISC",
@tstout
tstout / install-jxbrowser-local.sh
Created March 21, 2019 13:03
install-jxbrowser-local #jxbrowser #maven
mvn install:install-file \
-Dfile=./Downloads/license.jar \
-DgroupId=com.teamdev.license \
-DartifactId=license \
-Dversion=6.23 \
-Dpackaging=jar \
-DgeneratePom=true;
mvn install:install-file \
-Dfile=./Downloads/jxbrowser-6.23-cross-desktop-win_mac_linux/lib/jxbrowser-win32-6.23.jar \
@tstout
tstout / iter-to-stream.java
Created January 30, 2019 11:06
iterator-to-stream #java
private JSONObject findWall(String match){
JSONArray walls = getWalls(this.jsonObject);
return StreamSupport.stream(walls.spliterator(), false)
.map(w -> (JSONObject)w)
.filter(w -> w.getString("id").equals(match))
.findFirst()
.orElseThrow(() -> new IllegalStateException(format("Wall Id %s not found", match)));
}