Skip to content

Instantly share code, notes, and snippets.

View wsoczynski's full-sized avatar

Wojciech Soczyński wsoczynski

  • London, United Kingdom
View GitHub Profile
@wsoczynski
wsoczynski / gist:4025093
Created November 6, 2012 14:41
Optional 2
class Main {
public Optional<String> someValue = Optional.absent();
public static void main(String... arguments){
Main m = new Main();
String foo = m.someValue.or("default value");
System.out.println(foo); //outputs "defaultValue"
@wsoczynski
wsoczynski / gist:4025014
Created November 6, 2012 14:26
Optional 1
class Main {
public Optional<String> someValue = Optional.absent();
public Optional<String> someOtherValue = Optional.of("test");
public static void main(String... arguments){
Main m = new Main();
if(m.someValue.isPresent()){
@wsoczynski
wsoczynski / gist:2365239
Created April 12, 2012 06:50
Between Java and PHP - Arrays 2
<?php
$foo = array("ala", "ma", "kota");
foreach($foo as $text){
echo $text;
}
?>
@wsoczynski
wsoczynski / gist:2365217
Created April 12, 2012 06:48
Between Java and PHP - Arrays 1
<?php
$foo = array(
"bar" => 10,
"baz" => "zzz"
);
$foo54 = ["bar" => 10, "baz" => "zzz"]; //valid from php 5.4
?>
@wsoczynski
wsoczynski / gist:2146704
Created March 21, 2012 12:55
Wiedz, że coś się dzieje 6
class TestSubject3refactored(doFoo1: DoFoo1, doFoo2: DoFoo2) {
val prop1 = 1;
val prop2 = 2;
def doFoo():Boolean = {
val someText = doFoo1.doFoo1(prop1)
val textToSend = doFoo2.doFoo2(someText, prop2)
return callSomeWebService(textToSend)
@wsoczynski
wsoczynski / gist:2146605
Created March 21, 2012 12:29
Wiedz, że coś się dzieje 5
class TestSubject3 {
val prop1 = 1;
val prop2 = 2;
def doFoo():Boolean = {
val someText = doFoo1();
val textToSend = doFoo2(someText);
return callSomeWebService(textToSend);
@wsoczynski
wsoczynski / gist:2146273
Created March 21, 2012 11:14
Wiedz, że coś się dzieje 4
class BazRefactored(bar: Bar) {
def doRealyFoo(input: Int):Int = {
return bar.i + input
}
}
class BazRefactoredMock extends BazRefactored(new Bar(10)) {
}
@wsoczynski
wsoczynski / gist:2146191
Created March 21, 2012 11:00
Wiedz, że coś się dzieje 3
class Bar(var i: Int) {
}
class Baz(bar: Bar) {
var barProperty = bar
}
class TestSubject2 {
@wsoczynski
wsoczynski / gist:2146098
Created March 21, 2012 10:42
Wiedz, że coś się dzieje 2
class TestCase1refactored {
def doFoo(bar: Bar): Bar = {
val result = new Bar(bar.i + 10)
return result
}
}
def testCase1refactored() {
@wsoczynski
wsoczynski / gist:2146039
Created March 21, 2012 10:27
Wiedz, że coś się dzieje 1
class Bar(var i: Int) {
}
class TestSubject1 {
def doFoo(bar: Bar){
bar.i = 10
}