Skip to content

Instantly share code, notes, and snippets.

View snusnu's full-sized avatar

Martin Gamsjaeger snusnu

View GitHub Profile
PATH
remote: /Users/snusnu/projects/github/shared/datamapper/dm-core
specs:
dm-core (1.0.2)
addressable (~> 2.2)
extlib (~> 0.9.15)
PATH
remote: /Users/snusnu/projects/github/shared/datamapper/dm-do-adapter
specs:
@snusnu
snusnu / gist:735602
Created December 10, 2010 00:57
DM relationship order bug
## Problem
Currently, relationships are stored in a hash. This means that the order in which they were created gets lost.
* A model with a composite primary key that is made up of two foreign keys (e.g. a join table)
* Only the relationships are defined (using #belongs_to)
* Properties are *not* explicitly defined (using #property)
class PersonTask
include DataMapper::Resource
@snusnu
snusnu / dm-veritas-gateway.rb
Created June 1, 2012 10:11
Mapping DM1 resources to veritas gateways
require 'dm-core'
require 'dm-migrations'
URI = 'postgres://localhost/test'.freeze
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, URI)
class Account
include DataMapper::Resource
@snusnu
snusnu / dm2-diagram.ly.xml
Created September 25, 2012 10:25
Save to file and open at http://www.diagram.ly
<mxGraphModel dx="1626" dy="1969" scale="0.833" grid="1" guides="1" tooltips="1" connect="1" fold="1" page="0" pageScale="1" pageWidth="826" pageHeight="1169" style="default-style2"><root><mxCell id="0"/><mxCell id="1" parent="0"/><mxCell id="46" value="" style="rounded=1" parent="1" vertex="1"><mxGeometry x="10" y="-10" width="770" height="340" as="geometry"/></mxCell><mxCell id="47" value="Address.belongs_to :user, User" style="text;fontFamily=Courier New;strokeWidth=1;fillColor=#999999;fontStyle=1" parent="1" vertex="1"><mxGeometry x="270" y="6.500000000000078" width="250" height="29" as="geometry"/></mxCell><mxCell id="48" value="" style="group;fontFamily=Courier New" parent="1" vertex="1" connectable="0"><mxGeometry x="125" y="86" width="520" height="80" as="geometry"/></mxCell><mxCell id="13" value="addresses__X__users" style="rhombus;fontFamily=Courier New" parent="48" vertex="1"><mxGeometry x="170" width="170" height="70" as="geometry"/></mxCell><mxCell id="27" value=":user" style="fontFamily=Courier
@snusnu
snusnu / gist:4027764
Created November 6, 2012 21:38
Current DM2 spec mutations
Heckle found 279 mutations that didn't cause spec violations
DataMapper::RelationRegistry::RelationNode contains the following poorly-specified methods:
- #initialize
DataMapper::RelationRegistry::RelationEdge contains the following poorly-specified methods:
- #relation
DataMapper::RelationRegistry::Builder::BaseBuilder contains the following poorly-specified methods:
- #name
@snusnu
snusnu / aliases.rb
Created December 11, 2012 04:00
minimal aliasing strategies for dm2
require 'equalizer'
require 'abstract_type'
module DataMapper
module Relation
class Graph
class Node
class Aliases
@snusnu
snusnu / campaign_ideas.md
Created February 22, 2013 17:10
Collecting ideas for a crowdfunding campaign for DataMapper 2

What we're building

We need to describe the overall goal we're trying to achieve with DM2, break it up into manageable small steps and come up with a realistic timeframe / amount of hours to make it happen.

How to reach out

  • Look through lanyrd and ask people we know if they can spread the word about our campaign at conferences
  • Contact popular podcasts and ask if they're willing to feature our campaign and ask people to contribute
  • changelog
@snusnu
snusnu / app.rb
Last active December 17, 2015 15:19
Example dummy app that uses substation, aequitas, ducktrap, anima and mustache. On rack.
require 'pp'
require 'adamantium'
require 'equalizer'
require 'concord'
require 'abstract_type'
require 'aequitas'
require 'ducktrap'
require 'anima'
require 'substation'

Graph::Node only exists because of our pimped jersey header that supports renaming the attributes during a join (and currently only a join, i.e. no support for other binary ops). If axiom would support Relation#join(other, join_definition) there would be no need for Graph::Node. The graph's nodes would be Axiom::Relation instances and the (directed) edges would continue to be composed of a name, a JoinDefinition instance and pointers to both source and target nodes.

ROM::Relation instances should be composed of an Axiom::Relation and a Mapper. Pushing the mapper to the tuple level renders our current AttributeSet useless, or rather, i suspect that its functionality will be subsumed in Mapper. If axiom would support an injectable EvaluatorContext for operations that accept a block (like #join etc), we should be able to come up with a context that is composed of the axiom relation and the mapper, thus allowing us to use "object land" attribute names inside the block, while still const

@snusnu
snusnu / vimrc
Created June 6, 2013 14:49
vimrc snippet to automatically strip trailing whitespace in code files
" a function that preserves the state
" see http://technotales.wordpress.com/2010/03/31/preserve-a-vim-function-that-keeps-your-state/
function! Preserve(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
execute a:command
" Clean up: restore previous search history, and cursor position