Discover gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Merb::Generators | |
class DatamapperModelGenerator < ComponentGenerator | |
# do stuff here | |
end | |
add_private :datamapper_model | |
ModelGenerator.invoke :datamapper_model, :orm => :datamapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -gt 0 ]; then | |
NAME=$1 | |
virt-install \ | |
--paravirt \ | |
--name=$NAME \ | |
--vcpus=1 \ | |
--ram=256 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foobar | |
puts "hallo there" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Nameable | |
# Assuming first_name and last_name are accessors. | |
def name=(name) | |
self.first_name, *_, self.last_name = name.split | |
end | |
def name | |
[first_name, last_name].compact.join(" ") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# actual stuff that matters | |
def generator_full_paths | |
@generator_full_paths ||= | |
Gem::cache.inject({}) do |latest, name_gem| | |
name, gem = name_gem | |
hem = latest[gem.name] | |
latest[gem.name] = gem if hem.nil? or gem.version > hem.version | |
latest | |
end.values.inject([]) do |mem, gem| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem structure: | |
/merb-slices | |
/lib | |
/spec | |
... | |
/merb_generators | |
/components | |
/slice_generator | |
/thin_slice_generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem structure: | |
/merb-slices | |
/lib | |
/spec | |
... | |
/merb_generators | |
/generators.rb # this is what we glob for | |
/slice_generator # this is required by generators.rb | |
/thin_slice_generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test{ | |
[Serializable] | |
[Securable] | |
[ThisPropertyIsAwesome] | |
public string Name{get; set;} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible " VIM extensions, not very VI compatible; | |
" this setting must be set because when vim | |
" finds a .vimrc on startup, it will set | |
" itself as "compatible" with vi | |
if has("syntax") | |
syntax on | |
endif | |
map BdW |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post < ActiveRecord::Base | |
has_many :comments | |
def comments=(attrs_array) | |
attrs_array.each do |attrs| | |
comments.create(attrs) | |
end | |
end | |
end |