Skip to content

Instantly share code, notes, and snippets.

View mslinn's full-sized avatar

Mike Slinn mslinn

View GitHub Profile
package com.promindis.game.snake.stm
import akka.actor.{ActorRef, Actor}
import java.awt.{Dimension, Graphics2D}
import java.awt.event.{ActionEvent, ActionListener}
import swing._
import swing.Dialog._
import swing.event.Key._
import swing.event.KeyPressed
@mslinn
mslinn / play
Created November 24, 2011 04:53
Play Framework 2.0 start script for Cygwin (should work on all *nix variants)
#! /usr/bin/env bash
control_c() {
if $cygwin; then rm "$USERPROFILE"/play.boot.properties; fi
exit 1
}
case "`uname`" in
CYGWIN*) cygwin=true;;
esac
@mslinn
mslinn / javap
Created February 18, 2012 19:51
Invoke javap with latest Scala 2.9.1 and Akka 2.0 jars from ivy cache
#!/bin/bash
# Author Mike Slinn
# Invoke javap with latest Scala 2.9.1 and Akka 2.0 jars
# Does not use SBT or scala scripts, so this actually works on all platforms that have bash,
# including Cygwin.
# Common Akka and Scala jars are included in the classpath, also the current SBT project
# class files if invoked from the root of an SBT project
# Invoke javap as usual with all options except classpath:
# javap scala.None
# You can add to the classpath with -cp, if that option is provided first:
@mslinn
mslinn / ForeachJava.java
Created February 19, 2012 18:35
Future.foreach() invoked from Java
import akka.actor.ActorSystem;
import akka.dispatch.*;
import com.typesafe.config.ConfigFactory;
import java.util.concurrent.Callable;
/** This example uses Future.future() to create a future that computes 2+3. */
class ForeachJava {
private final String configString = "akka { logConfigOnStart=off }";
ActorSystem system = ActorSystem.apply("actorSystem", ConfigFactory.parseString(configString));
@mslinn
mslinn / scala
Created February 20, 2012 03:33
Bulletproof Scala REPL that works on all platforms with bash and includes current project classes like SBT console
#!/bin/bash
# Author Mike Slinn
#
# Requires JAVA_HOME to be set
#
# Invoke scalac with latest Scala 2.9.1 and Akka 2.0 jars, and Include SBT/Maven compiled project
# classes if invoked from root of an SBT/Maven project
# Does not use SBT or scala scripts, so this actually works on all platforms that have bash,
# including Mac, Linux and Cygwin.
# Invoke scala as usual with all options except classpath.
@mslinn
mslinn / getSrch
Created February 20, 2012 15:42
Find the file in a git repo with the most occurrences of a string
#!/bin/bash
# Author: Mike Slinn
function FILES {
git grep -c $1|sort -t : -k 2 -n -r
}
ACTION=
while getopts "h1n" opt; do
case $opt in
@mslinn
mslinn / sbt
Created March 20, 2012 16:21
sbt scripts enhanced for Sublime-text 2
#!/bin/bash
# JAVA_HOME must be on the path
JAVA_OPTS="-Xss2m -Xmx512M -XX:MaxPermSize=128m -XX:+CMSClassUnloadingEnabled"
if [ $OSTYPE == cygwin ]; then
export CYGWIN="tty ntsec"
JAVA_OPTS="$JAVA_OPTS -Djline.terminal=jline.UnixTerminal"
fi
java $JAVA_OPTS -jar 'e:/storage/programming/scala/sbt-launch.jar' "$@"
@mslinn
mslinn / mongodb.config
Created March 24, 2012 03:18
MongoDB Setup
dbpath=D:\storage\programming\mongodb\mongodb-win32-x86_64-2.0.4\bin\data
journal=true
rest=true
@mslinn
mslinn / sbtDeps
Created July 12, 2012 21:13
Shows all dependencies of an SBT project
#!/bin/bash
echo "Direct dependencies"
sbt 'show all-dependencies' | \
gawk 'match($0, /List\((.*)\)/, a) {print a[1]}' | \
tr -d ' ' | tr ',' '\n' | sort -t ':' | \
tr ':' '\t' | expand -t 30
echo -e "\nAll dependencies, including transitive dependencies"
sbt 'show managed-classpath' | tr -d ' ' | tr ',' '\n' | \
@mslinn
mslinn / update.sh
Last active March 11, 2024 17:09
Bash Script to Update all Git Directories Below Specified Directories
#!/bin/bash
# Update all git directories below specified directories
# Skips directories that contain a file called .ignore
# See https://stackoverflow.com/a/61207488/553865
HIGHLIGHT="\e[01;34m"
NORMAL='\e[00m'
export PATH=${PATH/':./:'/:}