Skip to content

Instantly share code, notes, and snippets.

View mslinn's full-sized avatar

Mike Slinn mslinn

View GitHub Profile
@mslinn
mslinn / concord
Last active October 9, 2015 09:48
Word concordance of a directory tree
find . -type f -print0 | xargs -0 cat | sed 's/[[:punct:]|{|}]/ /g' | sed -r 's/\s+/\n/g' | sed 's/[[:digit:]]*//' |sort | uniq -c | sort -n | less
@mslinn
mslinn / notepad
Created September 18, 2012 16:26
RUn Notepad++ on cygwin
#!/bin/bash
if [ $# != 1 ]; then
echo "Usage: $(basename $0) filename"
echo " If filename is not found in the current directory then subdirectories are searched"
echo " The file is then edited in Notepad++"
exit -1
fi
if [ -f "$1" ]; then
FN=$1
else
@mslinn
mslinn / git-remove-history
Created December 11, 2012 20:33
Permanently remove file(s) from a git repository
#!/bin/bash
# see http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
# Author: David Underhill (original)
# Author: Mike Slinn (runs from any directory)
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-remove-history path1 path2
@mslinn
mslinn / commitAll
Created December 15, 2012 01:16
Commits all git and svn directories below current directory or specified directory Skips directories that contain a file called .ignore
#!/bin/bash
# Commits all git and svn directories below current directory or specified directory
# Skips directories that contain a file called .ignore
HIGHLIGHT="\e[01;34m"
NORMAL='\e[00m'
REPO=origin
MSG="-"
while getopts "dm:\?" opt; do
case $opt in
@mslinn
mslinn / javapDriver
Created December 18, 2012 23:28
Searches path for .class files compiled from specified Scala or Java class Usage: findClasses fileName [className] -c classpath; if not specified then all classes under target/scala-* are searched -e Exact match required for fileName, or className if specified -s Show javap decompilation output
#!/bin/bash
function help {
echo "Searches path for .class files compiled from specified Scala or Java class"
echo "Usage: $(basename $0) fileName [className]"
echo " -c classpath; if not specified then all classes under target/scala-* are searched"
echo " -e Exact match required for fileName, or className if specified"
echo " -s Show javap decompilation output"
exit -1
}
@mslinn
mslinn / PaypalController.scala
Last active June 9, 2017 22:22 — forked from alpeb/Paypal.scala
Paypal IPN script for Play 2.1
package controllers
import play.api._
import libs.ws.WS
import play.api.mvc._
import com.micronautics.paypal.{TransactionProcessor, PaypalTransactions}
import java.net.URLEncoder
import concurrent.{Await, ExecutionContext}
import concurrent.duration.Duration
import java.util.concurrent.TimeUnit
@mslinn
mslinn / PaypalTransaction.scala
Last active October 25, 2016 01:31
Attempt to persist entities with >22 fields via Slick. Cannot find documentation on how nested tuples are supposed to work; tried creating two helper classes (CustomerAddress and PaymentDetail). Compiler error is: scala: overloaded method value <> with alternatives: [R(in method <>)(in method <>)(in method <>)(in method <>)(in method <>)(in meth…
package com.micronautics.paypal
import java.util.{ List, Map }
import collection.JavaConversions._
import collection.immutable.HashMap
import controllers.Email
import org.joda.time.DateTime
import slick.driver.MySQLDriver.simple._
import java.util
@mslinn
mslinn / AnormTest.scala
Last active December 10, 2015 17:08
Play Anorm code that DOES insert >22 columns into a database, using Play 2.1 and Scala 2.10-RC5. I built Play 2.1 against Scala 2.10-RC5 using my fork of the project.
package com.micronautics.paypal
import play.api.db.DB
import anorm._
import play.api.Play.current
object AnormTest {
DB.withConnection { implicit connection =>
val sql = SQL(
"""insert into paypal_transaction(
@mslinn
mslinn / play
Created January 7, 2013 18:27
Bash script to run play on port 9001 and debug via JPDA on port 9998. Note that if the debug parameter is provided JPDA port 9999 cannot be overridden. This script shows how its done.
#!/bin/bash
export JPDA_PORT=9998
export play21='/home/mslinn/work/experiments/scala/Play20/play'
$play21 "run 9001"
@mslinn
mslinn / explorer
Last active December 14, 2015 03:28
Opens Windows Explorer in current directory from Cygwin bash prompt
#!/bin/bash
`cygpath -a $WINDIR/system32/explorer` /select,`cygpath -ad .`