Sunday, November 29, 2015

Java: Two ways to glob

Two ways of globbing.

First, using a DirectoryStream.  This is the better way.

    static List xglob(String filePath, String wc) {
        List result = new ArrayList();

        Path dir = FileSystems.getDefault().getPath(filePath);
        DirectoryStream stream = null;
        try {
            stream = Files.newDirectoryStream(dir, wc);
            for (Path path : stream) {
                result.add(path.getFileName().toString());
            }
            stream.close();

        } catch (IOException e) {
            // glob of something that does not exist is empty
        }
        return result;
    }

Second, using File().

    static List glob2(String dirname_s, String wc) {
        PathMatcher matcher = FileSystems.getDefault()
                                .getPathMatcher("glob:"+wc);
        List result = new ArrayList();

        File dircontents = new File(dirname_s);
        String[] paths = dircontents.list();

        for (String ps : paths) {
            Path p = Paths.get(ps);
            if (matcher.matches(p)) {
                result.add(p.toString());
            }
        }
        Collections.sort(result);
        return result;
    }

blogodex = {"idx" : ["glob", "java"]};

Sunday, November 22, 2015

Mac Installing Consolas font

I thought installing Office would install it in the Font Book.  Apparently not!

Here's how to get it into the Font Book.  Be sure and do this in a scratch directory as it creates a lot of files.

brew install cabextract
curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
cabextract PowerPointViewer.exe
cabextract ppviewer.cab
open CONSOLA*.TTF

blogodex = {"idx" : ["Consolas", "fonts", "Mac setup"]};

Friday, November 13, 2015

Saving Youtube Audio for iPhone playback

I'm watching a lot of tutorials these days on Youtube.  A lot of these are fine audio-only, and it would be nice to listen to them on the daily commute.

BUT, unlike the various audio players, the Youtube player pauses when you lock the screen.  So, here's some incantations to grab the audio.




I think an mp3 codec can be added to ffmpeg.  If anybody knows an easy incantation give me a shout! This may be it:

  • ffmpeg -i foo.mp4 -c:a libmp3lame -ac 2 -q:a 2 foo.mp3
blogodex = {"idx" : ["video conversion", "audio extraction", "Youtube"]};

Thursday, November 12, 2015

Kafka Training Deck


Covering:
  • Introducing Kafka: history, Kafka at LinkedIn, Kafka adoption in the industry, why Kafka
  • Kafka core concepts: topics, partitions, replicas, producers, consumers, brokers
  • Operating Kafka: architecture, hardware specs, deploying, monitoring, performance and scalability tuning
  • Developing Kafka apps: writing to Kafka, reading from Kafka, testing, serialization, compression, example apps (with kafka-storm-starter)
  • Playing with Kafka using Wirbelsturm

http://www.michael-noll.com/blog/2014/08/18/apache-kafka-training-deck-and-tutorial/

blogodex = {"idx" : ["kafka", "tutorials"]};

Tuesday, November 10, 2015

Oracle: quick AS OF demo

First, let's check our current SCN

    scott@orcl> select current_scn from v$database;
    current_scn
    -----------
    7559499070893

And see how many rows we have in table FOO

    scott@orcl> select count(*) from foo;
    count(*)
    --------
          33

Delete everything from FOO

    scott@orcl> delete from foo;
    (33 rows, 0.011 sec)

    scott@orcl> select count(*) from foo;
    count(*)
    --------
           0

What's our SCN now?

    scott@orcl> select current_scn from v$database;
    current_scn
    -----------
    7559499071397

What was the count as of yesterday?

    scott@orcl> select count(*) from foo as of timestamp sysdate-1;
    count(*)
    --------
          33

And as of the SCN at the start of our session?

    (1 rows, 0.010 sec)
    scott@orcl> select count(*) from foo as of scn 7559499070893;
    count(*)
    --------
          33

blogodex = {"toc" : "Oracle SCN", "idx" : ["Oracle", "SCN", "System Change Number", "as of"]};

Friday, November 6, 2015

Installing Maven

Pretty simple:

This was on a Mac.


blogodex = {"idx" : ["maven", "installation"]};

SQL Developer Keepalive plugin

When you start SQL Developer, click on the icon.  Pressing enter gives you the default of sending a message every 600 seconds.

https://github.com/scristalli/SQL-Developer-4-keepalive

blogodex = {"idx" : {"SQL Developer", "Oracle connection timeout", "ORA-03135"]};

Thursday, November 5, 2015

What if your name is actually Null?


Interesting comments by Mr. Christopher Null!

I'm adding "null" to the blogodex, will it come back to bite me?


blogodex = {"idx" : ["problem areas", "null"]};

Wednesday, November 4, 2015

Nice article on The Log

"Each working data pipeline is designed like a log; each broken data pipeline is broken in its own way."—Count Leo Tolstoy (translation by Jay Kreps)
Here's an excellent manifesto about "the data log".  You might be familiar with this concept in the guise of database journals, or with event sequences in distributed systems.

Jay starts from there and writes (pretty comprehensively!) about how this idea is used in several modern systems, and talks about his experience at linkedin using this approach.  Lots of interesting references at the end.  I was happy to see John Ousterhout mentioned there!

The Log: What every software engineer should know about real-time data's unifying abstraction

blogodex = {"idx" : ["logging", "Jay Kreps", "Kafka", "fundamentals", "scalability"]};