Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
jaytaylor / dbhelper.py
Created March 13, 2012 18:12
Python Database Helper
import MySQLdb
##
# @author Jay Taylor [@jtaylor]
# @date 2010-11-15
#
# @description This is a basic database helper script which will setup the connection.
#
# @requirements The MySQLdb package must be installed, i.e. `sudo easy_install MySQLdb`
#
@jaytaylor
jaytaylor / Parsify.scala
Created March 22, 2012 19:47
Scala term string parser
/**
* @author Jay Taylor [@jtaylor]
*
* @date 2011-08-29
*
* @description Eventually I'd like to see this (or something even better)
* included in the scala.sh library.
*/
trait Parsify {
@jaytaylor
jaytaylor / DatabasePoolConfigurator.scala
Created March 22, 2012 23:09
Play Framework 1.x C3PO Database pool configurator
import play.{configuration, Logger}
import com.mchange.v2.c3p0.ComboPooledDataSource
/**
* @author Jay Taylor [@jtaylor]
*
* @date 2012-03-22
*
* @description c3po Database connection pool configuration container and applicator.
*
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.routing
import akka.actor.{ UntypedActor, Actor, ActorRef, ForwardableChannel }
/**
* A Dispatcher is a trait whose purpose is to route incoming messages to actors.
@jaytaylor
jaytaylor / free.sh
Created March 22, 2012 23:22
Add this to your .bashrc or .bash_profile to get a `free` command in OS-X. Originally found at http://apple.stackexchange.com/questions/4286/is-there-a-mac-os-x-terminal-version-of-the-free-command-in-linux-systems
##
# How about a `free` command if we're on OS-X?
#
if [ -z "`which free`" ]; then
freePython="
import re, subprocess
# Get process info
ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0]
vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0]
# Iterate over all processes
@jaytaylor
jaytaylor / LazyInfo.scala
Created March 29, 2012 21:57
LazyInfo.scala
// Found at: http://www.scala-lang.org/node/7873 & https://gist.github.com/621684
/* NSC -- new Scala compiler
* Copyright 2005-2010 LAMP/EPFL
* @author Paul Phillips
*/
package common.utils
//package scala.tools.nsc
//package util
@jaytaylor
jaytaylor / NewAgePostgreSqlAdapter.scala
Created August 7, 2012 22:42
Squeryl Postgres adapter which activates proper sequence naming
import org.squeryl.adapters.PostgreSqlAdapter
class NewAgePostgreSqlAdapter extends PostgreSqlAdapter {
override val usePostgresSequenceNamingScheme: Boolean = true
}
@jaytaylor
jaytaylor / etc-init-elasticsearch.conf
Last active July 8, 2018 22:06
Ubuntu upstart service script for ElasticSearch on EC2 Large instance
# ElasticSearch upstart script
description "ElasticSearch service"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@jaytaylor
jaytaylor / parseUriParameters-using-java-collections.scala
Created August 28, 2012 22:08
Scala query string parser using Java Collections
import java.net.URLDecoder
import java.util.{ArrayList, HashMap, List, Map}
import scala.collection.JavaConversions._
/**
* Parse the query string portion of a string containing a URI or URL.
*/
/**
* Parse the query string portion of a string containing a URI or URL.
*/
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/reference/setup/installation.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,