Skip to content

Instantly share code, notes, and snippets.

View jaytaph's full-sized avatar
:shipit:
Calculating pi

Joshua Thijssen jaytaph

:shipit:
Calculating pi
View GitHub Profile
import io;
class Color {
// Keeps numerical RGB value of the color
protected property value;
// Internal list of color names and RGB pairs.
protected property names = hash[[
"white" : 0xFFFFFF,
import io;
class Color {
// Keeps numerical RGB value of the color
protected property value;
// Internal list of color names and RGB pairs.
protected property names = hash[[
"white" : 0xFFFFFF,
➜ saffire git:(cpuid) cat test.sf
import io,cpu;
io.println("CPU Info:");
io.println(" Vendor: ", cpu.vendor());
io.println(" Vendor ID: ", cpu.vendorId());
io.println(" Brand: ", cpu.brand());
io.println(" Codename: ", cpu.codename());
➜ webserver git:(moreup) ✗ sf webserver.sf 0.0.0.0 4000
> Serving Saffire on 0.0.0.0:4000
> Press CTRL-C to quit.
> Accepting connections...
O> GET / HTTP/1.1
_ _
| | (_)
_____ _____ ___ _ __ | |_ _ ___ _ __
/ _ \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \
| __/> < (_| __/ |_) | |_| | (_) | | | |
JSON 1: {"foo":"bar","foo2":"bar2","foo3":"bar3"}
JSON 2: {"foo":"bar","foo2":"bar2","foo3":"bar3"}
JSON 3: { "foo": "bar", "foo2": "bar2", "foo3": "bar3" }
JSON 4: {"foo":"bar","foo2":"bar2","foo3":"bar3"}
JSON 4: {
"foo":"bar",
"foo2":"bar2",
"foo3":"bar3"
}
JSON 5: {
#include "saffire.h"
#include <stdio.h>
Saffire::Object greet_method(Saffire::Arguments &args) {
Saffire::String s;
args.parse("s", &s);
return Saffire::String( std::string("hello ") + s.value() );
}
SAFFIRE_MODULE_METHOD(file, write) {
t_file_object *file_obj = (t_file_object *)self;
t_string_object *str_obj;
if (! object_parse_arguments(SAFFIRE_METHOD_ARGS, "s", &str_obj)) {
return NULL;
}
long bytes_written = fwrite(str_obj->data.value->val, 1, str_obj->data.value->len, file_obj->data.fp);
import io;
import file;
f = file.open("test.txt", "r");
io.print("FILE 1: ", f.path(), " => ", f.fileNo(), "\n");
f2 = file.open("test.txt", "r");
io.print("FILE 2: ", f2.path(), " => ", f2.fileNo(), "\n");
io.dump(f.stat());
interface DataInterface {
public method getData();
}
class NullableData implements DataInterface {
}
class chartA implements DataInterface {
}
class chartB implements DataInterface {
namespace Application;
class Controller {
protected $app;
function __construct($app) {
$this->app = $app;
}