Skip to content

Instantly share code, notes, and snippets.

View neovintage's full-sized avatar
😅
data is always moving

Rimas Silkaitis neovintage

😅
data is always moving
View GitHub Profile
@neovintage
neovintage / 404.html.erb
Created February 24, 2012 04:31
Precompile html in Rails3
<html>
<head>
<%= javascript_include_tag 'application' %>
</head>
<body>
Use sweet js functions here
</body>
</html>
@neovintage
neovintage / doc.json
Created December 17, 2011 17:17
Mongodb Versioning
{
"title": "Creating great content",
"content": "Ive got nothing",
"comments": [
]
"version": 2
"versions": [
{ "title": "Creating great content", "version": 1 }
]
}
@neovintage
neovintage / create.rb
Created December 17, 2011 17:09
Using Allocate to Create ActiveRecord Objects
j = Job.allocate
j.init_with('attributes' => {'name' => 'Awesome Shop', 'title' => 'Test Job', 'status' => 'complete'})
j.title # => 'Test Job'
@neovintage
neovintage / development.rb
Created December 17, 2011 17:04
Configuring Rails 3 Plugin
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.perform_deliveries = false
config.action_mailer.default :charset => "utf-8"
config.active_support.deprecation = :log
config.mongo_fifo = MongoFifo::Store.new(Mongo::Connection.new['mongo_fifo'])
@neovintage
neovintage / configure.sh
Created December 16, 2011 16:41
Shogun & Ruby
./configure --interfaces=ruby_modular --libs=/Users/rimas/.rvm/rubies/ruby-1.9.2-p290/lib --rubydir=/Users/rimas/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/x86_64-darwin10.8.0
@neovintage
neovintage / libsvm.rb
Created December 11, 2011 11:18
Libsvm Example
require 'libsvm'
# This library is namespaced.
problem = Libsvm::Problem.new
parameter = Libsvm::SvmParameter.new
parameter.cache_size = 1 # in megabytes
parameter.eps = 0.001
parameter.c = 10
@neovintage
neovintage / awesomeapp_resque.rb
Created December 11, 2011 10:59
Mounting Resque Server to Rails 3 with Devise and Warden
class Awesomeapp::Resque < Resque::Server
# Will redirect back to rails app to require a sign in
before do
env['warden'].authenticate!
end
end
@neovintage
neovintage / part1.rb
Created December 7, 2011 21:46
MongoDB tips
class Post
include Mongoid::Document
field :author
field :text
field :publish_date, :type => Date
embeds_many :comments
index [:author, :asc]
end
class Comment
@neovintage
neovintage / dm-mysql.rb
Created December 7, 2011 21:43
mysql options in datamapper
require 'dm-core'
require 'dm-mysql'
# Shows available options
class HasAllOption
include DataMapper::Resource
property :id, Serial
property :name, String
`echo "#{Process.pid}" > #{Merb.root}/log/metrics_gen.pid`
`echo "#{Process.ppid}" > #{Merb.root}/log/metrics_gen.ppid`