Skip to content

Instantly share code, notes, and snippets.

import sbt._
import Keys._
object VersionInfoPlugin extends Plugin {
val versionInfoPackage = SettingKey[String]("version-info-package")
val versionInfoClassTask = TaskKey[Seq[java.io.File]]("version-info-class", "writes a java class VersionInfo with information about the versionInfo to sourceManaged")
val versionInfo = TaskKey[String]("version-info", "the current versionInfo")
private val Classname = "VersionInfo"
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "javatest"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "javatest"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
@freekh
freekh / either.scala
Created June 28, 2012 16:36
for comprehension error handling
val aOpt: Option[Int] = Some(1)
val c = for {
a <- aOpt.toRight("Missing something in first level!").right
b <- Option(2).toRight("Another failure!").right
} yield {
a + b
}
@freekh
freekh / eclipse.scala
Created February 27, 2012 21:57
JUnitRunner for Eclipse
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
@RunWith(classOf[JUnitRunner])
@freekh
freekh / sbt.scala
Created February 27, 2012 21:56
Library dependencies
libraryDependencies ++= Seq(
"org.specs2" %% "specs2" % "1.8.2" % "test",
"junit" % "junit" % "4.7" % "test"
)
@freekh
freekh / infscroll.m
Created February 13, 2012 16:46
Infinity scroll
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y ==
self.table.contentSize.height - self.table.frame.size.height)
|| (self.table.contentSize.height - self.table.frame.size.height ) < 0) {
//When table is dragged this will be enabled
[self loadMoreElements];
}
}
@freekh
freekh / AsyncURLWrapper.h
Created February 9, 2012 10:15
AsyncURLWrapper
#import <Foundation/Foundation.h>
@class AsyncURLWrapper;
@protocol AsyncURLWrapperDelegate <NSObject>
@optional
- (void) didFinish: (NSData*) data sender: (AsyncURLWrapper*) urlWrapper response: (NSHTTPURLResponse*) response;
- (void) didFail: (NSError*) error sender: (AsyncURLWrapper*) urlWrapper;
- (void) beforeRetry: (NSError*) error sender: (AsyncURLWrapper*) urlWrapper;
- (void) didUpdateProgress: (float) percentCompleted sender: (AsyncURLWrapper*) urlWrapper;
@freekh
freekh / ViewController.m
Created February 9, 2012 10:13
All callbacks
#pragma mark - AsyncURLWrapper delegates
- (void) didFinish: (NSData*) data sender: (AsyncURLWrapper*) blob
{
if (blob == _asyncWrapper1) {
NSLog(@"string from wrapper 1: %@", [AsyncURLWrapper asUTF8String:data]);
}
if (blob == _asyncWrapper2) {
NSLog(@"string from wrapper 2: %@", [AsyncURLWrapper asUTF8String:data]);
}
}
@freekh
freekh / FinishCallback.m
Created February 9, 2012 10:07
Finish callback
- (void) didFinish: (NSData*) data sender: (AsyncURLWrapper*) blob
{
if (blob == _asyncWrapper1) {
NSLog(@"data 1: %@", data);
}
if (blob == _asyncWrapper2) {
NSLog(@"data 2: %@", data);
}
}