Skip to content

Instantly share code, notes, and snippets.

@josefbetancourt
josefbetancourt / FindFile.groovy
Created July 9, 2012 11:52
Use Groovy to find path of a file in a directory tree
import groovy.transform.TypeChecked
/**
* search file according to its name in directory and subdirectories
*/
@TypeChecked
class FileFind {
String basePath; // for unit testing
package com.octodecillion.util;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@josefbetancourt
josefbetancourt / HexDump.groovy
Last active September 13, 2016 15:25
Groovy Hex Dump
package com.octodecillion.util
import static java.lang.Character.*
/**
* Simple ASCII hex dump of file.
* <p>
* Example output:<br>
* <pre>
* OFFSET 0 1 2 3 4 5 6 7 8 9 a b c d e f | ASCII
@josefbetancourt
josefbetancourt / index.js
Last active August 12, 2016 01:55
Using Media Queries in React
import React from 'react';
import {render} from 'react-dom';
import "babel-polyfill";
import invariant from "invariant";
/**
* A P P
*
*/
var App = React.createClass({
@josefbetancourt
josefbetancourt / Toggle.js
Last active January 20, 2016 13:06
RxJS example of reactive toggable and cancellable process loop in browser
// Toggle.js RxJS example of reactive toggable and cancellable process loop
// By: Josef Betancourt
// Date: Jan 11, 2016
// =========== Model
var counter = 1;
var runningState = true;
var msg = '';
var runButtonValue = 'Start';
package com.octodecillion.learn.rxjava;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import rx.Observable;
/**
*
* @author jbetancourt
@josefbetancourt
josefbetancourt / HelloRxTest.java
Last active January 3, 2016 01:50
Hello world using RxJava.
package com.octodecillion.learn.rxjava;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Before;
@josefbetancourt
josefbetancourt / INIX-example.inix
Last active December 29, 2015 17:09
Inix file reader source code to accompany blog post "Groovy implementation of INIX file format"
# Example very simple data file
#
[>root]
one
two
three
[<root]
[>demo1/compile]
x,y,z
[<demo1/compile]
@josefbetancourt
josefbetancourt / GoGenerator.groovy
Created October 15, 2013 01:20
Code for blog post "Change dir batch generator using Groovy" on http://octodecillion.com
/**
* GoGenerator.groovy
* Copyright 2010 Josef Betancourt 20100312-17:47
*/
/*@Grapes([
@Grab(group='ch.qos.logback', module='logback-core', version='0.9.18'),
@Grab(group='ch.qos.logback', module='logback-classic', version='0.9.18'),
@Grab(group='org.slf4j', module='slf4j-api', version='1.5.10')])
@josefbetancourt
josefbetancourt / Gather.groovy
Last active December 23, 2015 18:59
Code to accompany "Parsing files using Groovy closures" on my blog.
package com.octodecillion
import java.nio.file.Files;
/**
* Simple folder walker and file parser.
* <p>
* Dev with Groovy 2.1.6, Java 7, Eclipse 4.3
*
* @author jbetancourt