Skip to content

Instantly share code, notes, and snippets.

View StefanKrecher's full-sized avatar

Stefan Krecher StefanKrecher

View GitHub Profile
//@version=2
study("RSI+MA", overlay=true)
// data series for RSI with length 14
rsi = rsi(close, 14)
// data series for Moving Average with length 9
ma = sma(close, 9)
// data series for buy signals:
//price should be below the moving average and RSI should be smaller than 40
// Booleans
false.ifTrue { assert false }.ifFalse { assert true };
// Exceptions
{-> throw new NullPointerException("Buh!") }.on(NullPointerException).do { e ->
assert e in Exception
assert e in NullPointerException
assert !(e in ArithmeticException)
@StefanKrecher
StefanKrecher / Smalltalk.groovy
Last active August 29, 2015 14:21
Smalltalkify Groovy: ifTrue/ ifFalse, on Exception do
class Smalltalk {
static Boolean ifTrue (Boolean self, Closure c) {
if(self) c()
self
}
static Boolean ifFalse (Boolean self, Closure c) {
if(!self) c()
self
}
static Boolean 'do' (Boolean self, Closure c) {
@StefanKrecher
StefanKrecher / workspace.st
Created September 19, 2012 15:34
simple workspace for GNU Smalltalk on Android
PackageLoader fileInPackage: 'Android'.
| layout event droid samples |
droid := Android new.
layout := '<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@StefanKrecher
StefanKrecher / GET-Request+JFrame.st
Created January 5, 2012 15:13
Ambrhino (Smalltalk/Amber-, Java-, Javascript-Mixture) example: makes HTTP-GET-Request & display result on a JFrame
| url con is isr br line content pane frame |
<importPackage(java.net)>.
<importPackage(java.io)>.
url := <new URL('http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=Psalm+23&include-headings=false')>.
con := url openConnection.
is := con getInputStream.
isr := <new InputStreamReader(is)>.
br := <new BufferedReader(isr)>.
content := ''.
line := ''.