Skip to content

Instantly share code, notes, and snippets.

View joshthecoder's full-sized avatar

Joshua Roesslein joshthecoder

View GitHub Profile
factorial: func(n: Int) -> Double {
result: Double = 1
while(n != 0) {
result *= n
n -= 1
}
return result
}
@joshthecoder
joshthecoder / gist:322500
Created March 5, 2010 06:34
GSOC project ideas for ooc
ooc Google Summer of Code project ideas
=======================================
- rock backend (llvm, javascript, jvm?)
- testing framework
- ooc-web improvements
- true exception support
- game/graphics engine (maybe bind ogre or start from scratch?)
- reincarnate and/or package store
- database library (couchdb, mongodb, sql)
HeaderMap: class extends HashMap<String> {
init: func ~headermap {
init(100)
}
init: func ~headermapWithCapacity (capacity: UInt) {
T = String
super(capacity)
}
}
import text/regexp/Regexp
main: func {
r := Regexp new("^test$")
if (r matches("test")) {
"match!" println()
}
}
import threading/[Runnable, Thread]
MyRunnable: class extends Runnable {
run: func {
// do work here
}
}
t := Thread new(MyRunnable new())
t start()
diff --git a/gtk/Gtk.ooc b/gtk/Gtk.ooc
index 54679fd..a94890d 100644
--- a/gtk/Gtk.ooc
+++ b/gtk/Gtk.ooc
@@ -19,7 +19,7 @@ Gtk: cover {
/**
* Start the Gtk main loop
*/
- main: extern(gtk_main) static func
+ start: extern(gtk_main) static func
Animal: class {
eat: func -> String { return "eating stuff" }
}
Bird: class extends Animal {
eat: func -> String { return "eating worms" }
}
main: func () {
define: func -> Func {
return func { printf("X is %d\n", 28) }
}
f: Func
f = define()
f()
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method
#!/usr/bin/env python
# Usage: trim <url to shorten>
# A simple script that trims long urls using tr.im
# Requires the shorty library (http://github.com/joshthecoder/shorty-python).
# This script is public domain.
# Author: Joshua Roesslein
import sys
from shorty import Trim, ShortyError