Skip to content

Instantly share code, notes, and snippets.

Avatar
🙈
🙉🙊

Marco Otte-Witte marcoow

🙈
🙉🙊
View GitHub Profile
View gist:150205
// application library 1
namespace App\Lib1;
const MYCONST = 'App\Lib1\MYCONST';
function MyFunction() {
return __FUNCTION__;
}
class MyClass {
View gist:150206
[request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObjects:@"articles", @"articles.features", nil]];
View gist:150207
Basket.all(:include => { :articles => :features})
View gist:150211
sudo gem install do_mysql -- --with-mysql-dir=/usr/local/mysql
View gist:202333
class ShoppingBasket < ActiveRecord::Base
def initialize(items = [])
self.items = items
end
end
View gist:202339
$ excellent shopping_basket.rb
Excellent result:
test.rb
* Line 1: ShoppingBasket does not validate any attributes.
* Line 1: ShoppingBasket defines initialize method.
* Line 1: ShoppingBasket does not specify attr_accessible.
Found 3 warnings.
View gist:210760
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 74 | 57 | 4 | 6 | 1 | 7 |
| Helpers | 32 | 23 | 0 | 2 | 0 | 9 |
| Models | 497 | 319 | 13 | 22 | 1 | 12 |
| Libraries | 499 | 282 | 5 | 35 | 7 | 6 |
| Model specs | 942 | 658 | 0 | 5 | 0 | 129 |
| View specs | 0 | 0 | 0 | 0 | 0 | 0 |
| Controller specs | 471 | 315 | 0 | 6 | 0 | 50 |
View gist:211804
class ArbitraryModel < DataMapper::Type
primitive String
def self.dump(value, property)
"#{value.class}/#{value.id}" unless value.nil?
end
def self.load(value, property)
case value
View gist:211805
class SomeModel
include DataMapper::Resource
property :id, Serial
property :details, ArbitraryModel
end