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
rsync -vaz --delete source/* 'copy 1'/ |
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
library | |
build-depends: base, HUnit | |
exposed-modules: Module.Name | |
Hs-Source-Dirs: src |
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
cd /System/Library/Frameworks/JavaVM.framework/Versions/ | |
sudo rm Current | |
sudo ln -s [Java version folder] Current |
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
public class Basket{ | |
private List<LineItem> lineItems = ... | |
public List<Product> getProductsOfType(String type){ | |
List<Product> products = new ArrayList<Product>(); | |
for(LineItem item : lineItems){ | |
if(item.getProductType().equals(type) | |
products.add(item.getProduct()); | |
} | |
return products; |
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
// simple example of the cake pattern | |
// abstract DAO trait | |
trait Repository[A, B]{ | |
// saves an entity, returns an ID | |
def save(entity: A): B | |
// more features.. | |
} | |
trait RdbmsRepository extends Repository[MyUserCaseClass, Long]{ |
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
// WTF's added by me, class cut down for brevity. | |
public class ModelAndView { | |
// WTF?! | |
/** View instance or view name String */ | |
private Object view; | |
public ModelAndView(String viewName) { | |
this.view = viewName; |
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
// Note this requires scalaz-core 7.0 added to the classpath. | |
import scalaz._ | |
import Scalaz._ | |
import Lens._ | |
case class Address(street: String, country: String) | |
case class User(name: String, address: Address) | |
val address = Address("Monkey Street", "England") | |
val user = User("Sean", address) |
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
viewContent.map{content => | |
val model = mergedModel.updated(template.contentPlaceHolder, content) | |
val content = render(template.name, model) | |
template.parent.map(layout => Scalate(layout, model, Some(content))).getOrElse(content) | |
} |
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
// Aim: Given a trait Client, I want to have one possible implementation that uses type classes to | |
//implement Clients abstract function, WITHOUT leaking through this fact to the Client traits API signature, | |
//as there are other, non- typeclass using impls. | |
trait Mapper[A]{ | |
def map(s: String): A | |
} | |
object Mapper{ | |
implicit object StringMapper extends Mapper[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
(defn get-or-else [value default] | |
(if (nil? value) | |
(if (ifn? default) | |
(default) | |
default) | |
value)) | |
(defn m-bind [value function] | |
(if (nil? value) | |
nil |