Skip to content

Instantly share code, notes, and snippets.

View mgonto's full-sized avatar

Martin Gontovnikas mgonto

View GitHub Profile
@mgonto
mgonto / create.scala
Created December 19, 2012 20:06
Create
val person = FactoryPal.create[Person]
@mgonto
mgonto / Create-override.scala
Last active December 9, 2015 22:48
Create with overriders
val person = FactoryPal.create[Person]() { (person : ObjectBuilder[Person]) =>
person.age.mapsTo(45) alone
}
@mgonto
mgonto / register.scala
Created December 21, 2012 19:41
FactoryPal multiple template register
//Default template creation
FactoryPal.register[Person]() { person =>
person.name.mapsTo("gonto") and
person.age.isRandom
}
//Creating template for a certain name. This way you can create multiple templates for a certain class
FactoryPal.register[Person](Some('coolPerson)) { person =>
person.name.mapsTo("cool") and
person.age.isRandom
@mgonto
mgonto / create.scala
Last active December 10, 2015 00:59
FactoryPal multiple template per class creation
//Create a person from default template
val person = FactoryPal.create[Person]
//Creating a Person for cool template
val person = FactoryPal.create[Person](Some('coolPerson))()
@mgonto
mgonto / Build.scala
Last active December 11, 2015 03:08
FactoryPal 0.2 build
import sbt._
import sbt.Keys._
object ApplicationBuild extends Build {
lazy val root = Project(
id = "factory_pal_sample",
base = file("."),
settings = Project.defaultSettings ++ Seq(
name := "factory_pal_sample",
@mgonto
mgonto / Output.txt
Created January 23, 2013 03:18
Scanner
nfo] Compiling 2 Scala sources to /Users/gonto/repos/fp2/framework-src/target/scala-2.10/classes...
Children are List()[info]
Compiling 1 Scala source to /Users/gonto/repos/fp2/framework-src/target/scala-2.10/test-classes...
Children are List(class PalObject1, class PalObject2)Children are List(class PalObject1, class PalObject2)0Set()[info]
@mgonto
mgonto / json_controller.rb
Created February 26, 2013 03:11
Json controller
class UsersController < ApplicationController
respond_to :json
before_filter :authenticate_user!, :only => :destroy
def create
@user = User.new(params[:user])
if @user.save
respond_with @user, status: :created
else
// bad
if (currentUser) {
function test() {
console.log('Nope.');
}
}
// good
if (currentUser) {
var test = function test() {
@mgonto
mgonto / app.js
Last active December 15, 2015 07:49
var module = angular.module('basicsite',
['ngResource']).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/',
{templateUrl: '/js//views/main.html', controller: 'MainCtrl'}).
when('/sports',
{templateUrl: '/js/views/sports.html', controller: 'SportsCtrl'}).
when('/players',
{templateUrl: '/js/views/players.html', controller: 'PlayersCtrl'}).
@mgonto
mgonto / directives.js
Created March 23, 2013 03:20
Footer Angular
module.directive('footer', function () {
return {
restrict: 'A', //This menas that it will be used as an attribute and NOT as an element. I don't like creating custom HTML elements
replace: true,
templateUrl: "/js/directives/footer.html",
controller: ['$scope', '$filter', function ($scope, $filter) {
// Your behaviour goes here :)
}]
}
});