Skip to content

Instantly share code, notes, and snippets.

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
#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;
#include <string>
#include <iostream>
#include <boost/foreach.hpp>
int main()
{
std::string hello( "Hello, world!" );
BOOST_FOREACH( char ch, hello )
{
#include <boost/thread/thread.hpp>
#include <iostream>
int count = 0;
boost::mutex mutex;
void increment_count()
{
boost::mutex::scoped_lock lock(mutex);
std::cout << "count = " << ++count << std::endl;
development: &defaults
# These are the settings for repository :default
# adapter: sqlite3
# database: sample_development.db
adapter: couchdb
database: database
host: localhost
port: 4004
match("/database").to(:controller => "proxy", :action => "index" )
match("/database/:id").to(:controller => "proxy", :action => "index" )
class People
include DataMapper::CouchResource
property :id, String, :serial => true, :key => true, :field => :_id
property :rev, String, :field => :_rev
property :title, String
end