This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # Requires the `ghi` command line tool (https://github.com/stephencelis/ghi) | |
| # Be sure to generate an API token from GitHub via Settings > Applications > Generate New Token | |
| import os | |
| import commands | |
| import re | |
| import string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # This requires ghostscript. It can probably be installed via your package manager. | |
| # e.g. `brew install ghostscript` | |
| if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | |
| cat <<HERE | |
| Usage: $0 <file.pdf> [-p | <password>] | |
| Creates a new file named 'file.pdf-decrypted.pdf' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait ToEither[A, B] { def toEither: Either[A, B] } | |
| implicit def tryToEither[A](t: Try[A]): ToEither[Throwable, A] = new ToEither[Throwable, A] { | |
| def toEither = t.map(Right(_)).recover{ case e => Left(e) }.get | |
| } | |
| // Usage | |
| scala> Try { "foo" }.toEither | |
| res0: scala.util.Either[Throwable,String] = Right(foo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Since OSX can't do `readlink -f` out of the box. | |
| BASE_DIR=$(cd $(dirname $0) && echo $PWD) | |
| IDEA_HOME=$(grep idea.home "$BASE_DIR/build.properties" | cut -d = -f 2) | |
| IDEA_JARS=$(find "$IDEA_HOME/lib" -name "*.jar") | |
| LOCAL_JARS=$(find "$BASE_DIR/lib" -name "*.jar") | |
| PRODUCTION_CLASSES=$(find "$BASE_DIR/out/production" -maxdepth 1 -type d) | |
| CLASSPATH=${IDEA_JARS//$'\n'/:}:${LOCAL_JARS//$'\n'/:}:${PRODUCTION_CLASSES//$'\n'/:} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Provides a .nullMap() method for Option which wraps potentially null results in an Option. | |
| * Example: | |
| * foo.getBar().getBaz() <- one of these might be null | |
| * Option(foo).nullMap(_.getBar()).nullMap(_.getBaz()) <- returns None if any value was null. | |
| */ | |
| implicit class ToOptionNullMap[A](o: Option[A]) { | |
| def nullMap[B](f: A => B): Option[B] = o.flatMap(a => Option(f(a))) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object SComboBoxMacro { | |
| def impl(c: Context) = { | |
| import c.universe._ | |
| Class.forName("javax.swing.JComboBox").getTypeParameters.length match { | |
| case 1 => reify { javax.swing.JComboBox[Object] } | |
| case 0 => reify { javax.swing.JComboBox } | |
| } | |
| } | |
| type SComboBox = macro impl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.haskforce.ui; | |
| import javax.accessibility.Accessible; | |
| import javax.accessibility.AccessibleContext; | |
| import javax.swing.*; | |
| import javax.swing.border.Border; | |
| import javax.swing.event.AncestorListener; | |
| import javax.swing.event.ListDataListener; | |
| import javax.swing.event.PopupMenuListener; | |
| import javax.swing.plaf.ComboBoxUI; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Flips the last two arguments | |
| usage() { | |
| echo "Usage: $0 <command arg1 arg2> [... argN]" | |
| echo | |
| echo "Flips the last two arguments of a command." | |
| echo | |
| echo "Example: \$ flip echo foo bar baz" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.haskforce.ui | |
| import javax.swing.JComboBox | |
| /** | |
| * Scala-friendly JComboBox; see [[SComboBoxMacro]] for more details. | |
| */ | |
| @SComboBoxMacro class SComboBox[E] extends JComboBox[E] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foreign import traceId | |
| """ | |
| function traceId(string) { | |
| return function(a) { | |
| console.log(string); | |
| return a; | |
| }; | |
| } | |
| """ :: forall a. String -> a -> a |