Skip to content

Instantly share code, notes, and snippets.

View biilmann's full-sized avatar
💭
Waiting for pod to exist...

Mathias Biilmann biilmann

💭
Waiting for pod to exist...
View GitHub Profile
@biilmann
biilmann / Http-Ennumerator.hs
Created March 15, 2011 05:13
Upload to rackspace with CURL
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.List as L
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as LB
import qualified Network.HTTP.Enumerator as HTTP
import Network (withSocketsDo)
import System.Posix.Env
import System.IO
@biilmann
biilmann / index.tpl
Created April 23, 2011 03:51
Twitter Timeline Extension for Webpop
<!DOCTYPE html>
<html>
<head>
<title>My Tweets</title>
</head>
<body>
<h1>My Tweets</h1>
<pop:twitter:timeline screen_name="webpop" wrap="ul" break="li">
<a href="http://twitter.com/#!/MadinSpain/status/<pop:id_str />"><pop:text /></a>
</pop:twitter:timeline>
@biilmann
biilmann / example-1.rb
Created May 5, 2011 18:29
JRuby - Rhino
# This is enough to get going
require 'java'
require 'vendor/rhino'
module JS
include_package 'org.mozilla.javascript'
end
context = JS::Context.enter
@biilmann
biilmann / example-3.rb
Created May 8, 2011 02:37
Akka AMQP from JRuby
$: << 'vendor/akka'
require 'java'
require 'akka-modules-1.0'
require 'net/http'
module Akka
include_package 'akka.actor'
include_package 'akka.amqp'
include_package 'akka.dispatch'
@biilmann
biilmann / gist:970320
Created May 13, 2011 10:31
Chef Server failing gem install
Building native extensions. This could take a while...
ERROR: Error installing chef-server:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for main() in -lgecodesearch... yes
checking for main() in -lgecodeint... yes
checking for main() in -lgecodekernel... yes
checking for main() in -lgecodesupport... yes
checking for main() in -lgecodeminimodel... yes
{
"title": "Hello, World",
"custom_fields": {
"name": "Hello"
}
}
@biilmann
biilmann / Readme.md
Created June 27, 2011 18:49
Form extension for Webpop

Forms with the Contact extension

This contact extension for Webpop is based on writing HTML5 forms with all the validations the HTML5 spec introduces, and having Webpop carry out the validations server-side in case the browser doesn't support them (or has been sidestepped completely).

To use it, simply copy "contact.js" into the Extensions folder of your project.

Writing forms with the <pop:contact> extension is very straight forward, and while the extension can easily be used to output forms with a predefined markup, every part of the final html can be handcrafted.

Here's a simple contact form:

@biilmann
biilmann / api.js
Created July 24, 2011 14:16
JSON API in 8 lines
exports.get = {
"api/:section": function(params) {
response.send(site.content({from: params.section}));
},
"api/:section/entries": function(params) {
response.send(JSON.stringify(site.entries({from: params.section})), {"Content-Type": "application/json"});
}
};
@biilmann
biilmann / index_content.rb
Created July 29, 2011 09:42
Indexing stuff
class Content
# ...
def to_indexed_json
{
:type => "content",
:id => id,
:project_id => id,
:section_id => section_id,
:category_id => attributes["category_id"],
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Control.Monad.Trans
import Control.Concurrent
import Snap.Types
import Snap.Util.FileServe
import Snap.Http.Server
import Snap.Iteratee