Skip to content

Instantly share code, notes, and snippets.

# strona.rb
require 'rubygems'
require 'sinatra'
get '/' do
'Cze!'
end
require 'rubygems'
require 'sinatra'
get '/' do
erb :index
end
use_in_file_templates!
get '/:permalink' do
# dopasowany wzorzec bedzie w params[:permalink]
end
module Yeti
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
def crud(klass,opts = {})
class_variable_set(:@@model,klass)
self.class_eval CRUD_CODE
end
@JakubOboza
JakubOboza / gist:30696
Created December 1, 2008 10:03
Using yaml dump with Active Record
class Comatose::Page < ActiveRecord::Base
end
desc "load pages"
task :load_pages_to_db => :environment do
YAML::add_private_type("Comatose::Page") do |type, value|
Comatose::Page.new(value)
end
#include <stdio.h>
int main(void)
{
int ch;
while ((ch = getchar()) != EOF)
putchar(ch);
putchar('\n');
return 0;
}
@JakubOboza
JakubOboza / gist:30811
Created December 1, 2008 19:42
Pcre lib shoot
#include <pcreposix.h>
#include <stdio.h>
int main(void)
{
regex_t rx;
char *pat = "([0-2]?\\d{1,2})\\.([0-2]?\\d{1,2})\\.([0-2]?\\d{1,2})\\.([0-2]?\\d{1,2})";
// More "ambitious" expression - "(?:([0-2]?\\d{1,2})\\.){3}([0-2]?\\d{1,2})";
char *str = "123.45.67.89";
regmatch_t match [6];
(define (pmatch el)
(lambda (parser)
(p-cond parser
((lambda (parser)
(if (eqv? (p-car parser) el)
(p-advance parser)
(p-fail-parser parser)))))))
(define (pmany op)
(lambda (parser)
(letrec ((loop (lambda (cur-stream)
#include <iostream>
#include <pcrecpp.h>
#include <string>
#include <map>
#include <fstream>
#define LINE_SIZE 256
typedef std::map<std::string,std::string> Hash;
development: &defaults
# These are the settings for repository :default
# adapter: sqlite3
# database: sample_development.db
adapter: couchdb
database: database
host: localhost
port: 4004