Skip to content

Instantly share code, notes, and snippets.

@bowmanb
bowmanb / SavedTabsFragment.java
Last active December 6, 2020 23:52
A basic Android ExpandableListFragment (SavedTabsFragment) example.
package com.advinture.ukuleletabs.fragments;
import android.app.ExpandableListActivity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
@bowmanb
bowmanb / build.sbt
Created November 20, 2012 05:47
scala md5 string as string
...
libraryDependencies += "commons-codec" % "commons-codec" % "1.7"
...
@bowmanb
bowmanb / quicksort.hs
Last active October 13, 2015 17:27
Quicksort in Haskell, from Learn You a Haskell for Great Good! Optimization courtesy of @saolsen.
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort [x] = [x]
quicksort (x:xs) =
let smallerOrEqual = [a | a <- xs, a <= x]
larger = [a | a <- xs, a > x]
in quicksort smallerOrEqual ++ [x] ++ quicksort larger
-- using filter
quicksort' :: (Ord a) => [a] -> [a]
@bowmanb
bowmanb / pom.xml
Created July 20, 2013 04:37
Maven pom.xml boilerplate
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
</project>
@bowmanb
bowmanb / http_server.clj
Last active April 7, 2024 03:02
An example Jetty component using Stuart Sierra's component Clojure library.
(ns my-project.http-server
(:require [compojure.core :as compojure]
[com.stuartsierra.component :as component]
[my-project.my-resource :as my-resource]
[ring.adapter.jetty :as jetty]))
(compojure/defroutes app
my-resource/handler)
(defrecord HTTPServer [port server]
@bowmanb
bowmanb / keybase.md
Created August 12, 2014 21:03
keybase.md

Keybase proof

I hereby claim:

  • I am bowmanb on github.
  • I am bowmanb (https://keybase.io/bowmanb) on keybase.
  • I have a public key whose fingerprint is 17ED FF08 BF69 4CB1 E651 8ECA 8C62 4B8F B2A0 D942

To claim this, I am signing this object:

@bowmanb
bowmanb / RxJavaCollectExample.java
Last active February 22, 2020 14:07
RxJava collect() example. Converting a list of phrases into a list of their IDs only.
@Override
public void onNext(ArrayList<Phrase> phrases) {
ArrayList<Integer> phraseIDs = new ArrayList<>();
Observable
.from(phrases)
.collect(phraseIDs, new Action2<ArrayList<Integer>, Phrase>() {
@Override
public void call(ArrayList<Integer> integers, Phrase phrase) {
integers.add(phrase.getId());
}
@bowmanb
bowmanb / Main.java
Last active May 9, 2016 17:14
Swagger property sorter
public class Main {
public static void main(String[] args) {
Swagger swagger = new SwaggerParser().read("swagger.json");
sortDefinitionProperties(swagger);
try {
FileUtils.writeStringToFile(new File("swagger-output.json"), Json.pretty(swagger), Charset.defaultCharset());
} catch (IOException e) {
e.printStackTrace();
}
}
@bowmanb
bowmanb / Params.java
Last active May 13, 2016 13:35
Java XSL transform w/ parameters only
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
public class Params {
public static void main(String[] args) {
try {