Skip to content

Instantly share code, notes, and snippets.

View zentrope's full-sized avatar

Keith Irwin zentrope

  • Portland, Oregon
View GitHub Profile
@zentrope
zentrope / Makefile
Last active September 6, 2015 17:54 — forked from rauhs/Makefile
Compiling clojurescript + figwheel without boot nor leiningen. Using leiningen to manage dependencies.
CLJ_NREPL_PORT:=22340
CLJS_JAR_VERSION:=1.7.48
CLJS_JAR_URL:=https://github.com/clojure/clojurescript/releases/download/r$(CLJS_JAR_VERSION)/cljs.jar
.PHONY: def_target
def_target : null
# http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html
package zentrope.hornet {
import scala.actors._
import org.hornetq.api.core._
import org.hornetq.api.core.client._
// ----------------------------------------------------------------------
private object Util {
package zentrope.sql {
import java.sql.SQLException
class Settings (
val url : String,
val user: String,
val pass: String,
val driver: String
)
// A small chat server in order to work out the details of a
// socket server using Actors. And maybe just a little attempt
// to wrap TCP itself inside an Actor, kinda like Erlang does
// it. The whole idea is to try and make things seem simpler,
// ultimately, and to remove any shared state.
package zentrope.chat {
import java.net.Socket
import java.net.ServerSocket
// A small chat server in order to work out the details of a
// socket server using Actors. And maybe just a little attempt
// to wrap TCP itself inside an Actor, kinda like Erlang does
// it. The whole idea is to try and make things seem simpler,
// ultimately, and to remove any shared state.
package zentrope.chat {
import java.net.Socket
import java.net.ServerSocket
private class Http(val address: String) {
// Simple class for snagging content from and posting content
// to a URL. No error handling.
import java.net._
import java.io._
import scala.io._
def get(): String = {
val url: URL = new URL(address)
@zentrope
zentrope / Delegate.scala
Created October 19, 2010 04:22
Example of having one actor create other actors to manage external resources dynamically.
// A sample app demonstrating one way to use actors to manage other
// actors created dynamically. Use case: an app that needs to maintain
// short-lived connections to remote resources (like a messaging queue).
import scala.actors._
import scala.actors.Actor._
class DelegateActor(val id: String) extends DaemonActor {
// Represents an actor that does some work, or hangs on to
// an external resource, such as a socket connection to an MQ
@zentrope
zentrope / ScalatePlugin.scala
Created June 9, 2011 21:21
Scalate Plugin using Source Generator for SBT 0.10.0
import sbt._
import Keys._
import Project.Initialize
import org.fusesource.scalate.TemplateSource
import org.fusesource.scalate.TemplateEngine
import java.io.File
@zentrope
zentrope / CoffeeScriptPlugin.scala
Created June 10, 2011 00:29
xsbt coffee script plugin (example) using sourceGenerators
import sbt._
import Keys._
import Process._
import Project.Initialize
import java.io.File
object CoffeeScriptPlugin extends Plugin {
@zentrope
zentrope / GenImage.scala
Created August 22, 2011 15:58
PNG on-the-fly image generation
import java.io.File
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
import java.awt.geom._
import java.awt.Color
import java.awt.Font
import java.awt.Graphics2D
import java.util.Date