Skip to content

Instantly share code, notes, and snippets.

View shelling's full-sized avatar

shelling shelling

View GitHub Profile
#!/usr/bin/env ruby
require "init"
p = Post.new
p.title = "first"
p.content = "hello world, this is my first entity"
p.save
package MyApp::DB;
my $dsn = "dbi:SQLite:dbname=test.sqlite3";
sub driver {
my $class = shift;
my $mode = shift;
if ($mode == "default") {
Data::Model::Driver::DBI->new( dsn => $dsn );
}
#!/usr/bin/env ruby
require 'rubygems'
require 'osx/cocoa'
app = OSX::NSApplication.sharedApplication
window = OSX::NSWindow.alloc.initWithContentRect_styleMask_backing_defer(
[0,0,500,500],
OSX::NSTitledWindowMask + OSX::NSClosableWindowMask,
#! /usr/bin/env guile
!#
(write '(a . (b c)))(newline)
;; (define push
;; (lambda (array scalar)
;; '(array . scalar)))
(define puts
(lambda (text)
(display text)(newline)))
(define print
(lambda (content)
#!/usr/bin/env perl
package User;
use Jifty::DBI::Schema;
use Jifty::DBI::Record schema {
column name =>
type is "text",
label is "Name",
render as "text";
<% my $person = "johnny" %>
person is <%= $person %>
<%= $var_out %>
@shelling
shelling / symbol-table.pl
Created August 7, 2009 07:59
Perl internal. package is just a special hash aka Symbol Table
#!/usr/bin/env perl
#
use 5.010;
package Hello;
our $var = "scalar";
our @var = qw(array);
@shelling
shelling / prototype.pl
Created August 7, 2009 13:51
prototype of Template::Declare and Markapl
#!/usr/bin/env perl
use Data::Dumper;
use 5.010;
BEGIN {
for my $tag (qw(html body table)) {
eval qq{
sub $tag (&) {
"<$tag>" . shift->() . "</$tag>";
@shelling
shelling / no-cgi.pl
Created August 8, 2009 17:48
CGI script without CGI.pm
#!/usr/bin/env perl
use 5.010;
say "Content-Type: text/html; charset=ISO-8859-1";
say;
say "hello, world! This is a cgi without CGI";