Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dnorton's full-sized avatar
🏠
Working from home

Daniel Norton dnorton

🏠
Working from home
View GitHub Profile
@dnorton
dnorton / java_8_lambda.java
Last active August 29, 2015 13:57
Just playing around with lambdas
package org.dnorton.java8.example;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*/
public class LambdaTest {
@dnorton
dnorton / java_8_streams.java
Created April 16, 2014 20:34
Fun with Java 8 Streams
Stream<String> sortedWords = Stream.of("The quick brown dog jumped".split("[\\P{L}]+")).sorted();
sortedWords.forEach(System.out::println);
files = [f for f in os.listdir('.') if ".sql" in f or ".pkg" in f]
@dnorton
dnorton / maven_and_intellij_capitalization.md
Last active August 29, 2015 14:02
Maven and IntelliJ slap fight

IntelliJ doesn't play well with Maven if directories don't use the correct capitalization.

<resource>
        <directory>${basedir}/src/java</directory>
        <includes>
          <include>*.xml</include>
        </includes>
</resource>
@dnorton
dnorton / file_match.py
Created January 8, 2015 22:22
find *.sh files
>>> import os
>>> import fnmatch
>>>
>>> for root, dirnames, filenames in os.walk('dir1'):
... for filename in fnmatch.filter(filenames, '*.sh'):
... print os.path.join(root, filename)
@dnorton
dnorton / dos2unix.sh
Last active August 29, 2015 14:13
dos2unix missing...
for i in `find my_dir -name '*.sh'`; do echo $i; sed 's/\r$//' $i $i.unix; cp $i $i.dos; cp $i.unix $i; done
@dnorton
dnorton / MetricsTest.java
Created April 29, 2015 14:47
Small Test for metrics library
package com.velogica.metrics;
import com.codahale.metrics.*;
import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
import com.codahale.metrics.jvm.ThreadStatesGaugeSet;
import org.junit.Test;
import rx.Observable;
import rx.functions.Action1;
@echo off
set DIR_BASE=C:\nonexisting_dir
:test_dir
if exist %DIR_BASE%\* (
echo %DIR_BASE% is a Directory
) else (
echo %DIR_BASE% is Not a Directory
set DIR_BASE=C:\existing_dir
@dnorton
dnorton / version.py
Last active December 15, 2015 10:28
attempting to order versions that are "#.#.##.##"
def _determine_version(artifact):
def determine_version(artifact):
base_path, symlink_name = os.path.split(artifact)
base_name = symlink_name.split('-')[0]
version = None
version_map = {}
version_list = []
list = os.listdir(base_path)
@dnorton
dnorton / exercise_slice.go
Created January 6, 2014 23:25
simple solution to Go Tour Slice Exercise
package main
/**
Implement Pic. It should return a slice of length dy, each element of which is a slice of dx 8-bit unsigned integers.
When you run the program, it will display your picture, interpreting the integers as grayscale (well, bluescale) values.
The choice of image is up to you. Interesting functions include x^y, (x+y)/2, and x*y.
(You need to use a loop to allocate each []uint8 inside the [][]uint8.)