Skip to content

Instantly share code, notes, and snippets.

function controlStuff(){
var listOfThings = loadThings()
for(thing in listOfThings.whereTypeIs(CanDoSomething)){
thing.doSomething()
}
}
// or just...
function controlStuff(){
classpath "tagsoup-1.2.1.jar,src"
uses gw.xml.simple.SimpleXmlNode
uses org.ccil.cowan.tagsoup.*
uses java.io.*
uses org.xml.sax.*
var src = "<html><body><table class='right halves'><tr></tr><tr></tr><tr><td>1</td><td>2</td><td>3</td></tr></table></body></html>"
var r = new Parser()
package hacks
uses gw.xml.simple.SimpleXmlNode
enhancement SimpleXmlNodeEnhancement : SimpleXmlNode {
function children( str : String ) : List<SimpleXmlNode> {
return this.Children.where( \ s -> s.Name == str )
}
}
print( "hello world" )
for( str in { "I", "love", "gosu" } ) {
print( str )
}
<%= form_for @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %>
<%= f.text_field :title %>
<%= f.text_area :body, :size => "60x12" %>
<%= f.submit "Create" %>
<% end %>
...
${formTag(ArticleController.create(article), :html = {"class" -> "nifty_form"} )}
${textField(article#Title)}
@1cg
1cg / hello_world.gsp
Created February 10, 2012 17:20
Hello World for Gosu
print( "Hello World" )
print( "You never thought we'd release, did you? ;p" )
<% var post = ... %>
${formFor(PostController#update(post))}
${input(post#Content)}<br/>
${submit("Update Post")}
${endForm}
## Something like this would poll the given url every 500ms and merge any new HTML into the div
## with a nice, clean, pluggable transition
<div data-model-endpoint="https://myserver/my-div-endpoint" data-model-update="poll 500ms">
...
</div>
## Something like this would poll the given url every 500ms and merge/delete the rows in a visually
## appealing manner like this fantastic plugin:
## http://www.scottlogic.com/blog/2011/01/04/animating-html-ranking-tables-with-javascript.html