Skip to content

Instantly share code, notes, and snippets.

View groundwater's full-sized avatar
:electron:
Performing Alchemy

Groundwater groundwater

:electron:
Performing Alchemy
View GitHub Profile
@groundwater
groundwater / Application.scala
Created April 11, 2012 05:34
Scala Anorm and Google Protocol Buffers
package controllers
import anorm._
import anorm.SqlParser._
import play.api.db.DB
import play.api.Play.current
import play.api._
import play.api.mvc._
javascript:
/* tldr.js copyright Seth Raphael 2011 */
void(initsumm());
function initsumm() {
initStopList();
var paragraphs = document.getElementsByTagName('p');
var rootContent;
if (!rootContent) rootContent = document.getElementById('post');
/*blogs*/
if (!rootContent) rootContent = document.getElementById('content');
@groundwater
groundwater / Application.scala
Created April 12, 2012 08:12
Play with HBase
package controllers
import play.api._
import play.api.mvc._
import com.googlecode.protobuf.format._
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.{ HTable, Put, Scan, Get }
import org.apache.hadoop.hbase.util.Bytes
@groundwater
groundwater / TransactionalCoprocessors.scala
Created April 20, 2012 06:02
Coprocessor Transactions in HBase and Scala
/** This builds a transactional layer into HBase via coprocessors.
*
* Transactions can be performed by sending a group of mutations,
* to a coprocessor. The coprocessor modifies the table using a
* special mutation protocol that ensures anyone using the same
* protocol will only view atomic commits.
*
* Querying the table directly does not guaruntee atomicity. You
* _must_ query using the provided protocol.
*
@groundwater
groundwater / HBaseTest.scala
Created April 20, 2012 09:32
HBase Coprocessor Test with Mocked HTableInterface and CoprocessorEnvironment
import org.specs2.mutable._
import org.specs2.mock._
import ca.underflow.MyApp
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.CoprocessorEnvironment
import org.apache.hadoop.hbase.client.{ HTableInterface, Put }
class HelloWorldSpec extends Specification with Mockito {
@groundwater
groundwater / asynchbase.scala
Created April 20, 2012 17:47
Demo Adapting asynchbase to Scala
package ca.underflow.hbase
import org.hbase.async._
import com.stumbleupon.async._
object Demo extends App {
// This let's us pass inline functions to the deferred
// object returned by most asynchbase methods
@groundwater
groundwater / README.md
Created April 29, 2012 04:29
Fetch Content from Crunchbase in Google Spreadsheets

Instructions

  1. Create a script in Google Spreadsheets and paste the code.
  2. Create a trigger to run fetch whenever the document is edited
  3. Go to the spreadsheet, type a company name in the A column and hit enter

The script should take the name, fetch data from crunchbase and insert a row with the requested data.

@groundwater
groundwater / blog.md
Created May 18, 2012 14:50
Why Method Overloading Sucks in Scala

Introduction

Method overloading sucks in Scala because it actually detracts from your flexibility. An implicit conversion is a feature of Scala that let's the compiler look up how to convert objects between types at compile time.

Let's say I define a method with the following signature:

def doSomething( action: Action )

Somewhere else in the code I write:

@groundwater
groundwater / .gitignore
Created July 20, 2012 05:09
iOS Git Ignore
# Exclude the build directory
build/*
# Exclude temp nibs and swap files
*~.nib
*.swp
# Exclude OS X folder attributes
.DS_Store
@groundwater
groundwater / blah.scala
Created August 6, 2012 18:18 — forked from mostlygeek/blah.scala
Some Scala
abstract class Prize {
def * (int x) = {
val list = List()
for (i=0; i<x; i++){
list.append( this )
}
list
}
}
case class CoinPrize(multipler: Int) extends Prize