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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / zoho_invoice_usage.rb
Created April 27, 2013 05:11
Zoho Invoice Usage
require 'zoho_invoice'
client = ZohoInvoice::Client.new(:authtoken => 'my authtoken', :apikey => 'my apikey')
invoice = ZohoInvoice::Invoice.new(client, :customer_id => 'asdf')
invoice.save
invoice = client.invoices.new(:customer_id => 'asdf')
invoice.save
# Background:
# I followed the initial url and your message suggested that I try json instead.
# Using that, I hit the initial page and tagged '.json' on to the url. You had
# mentioned in your job description that you were using rails so I figured I could
# do that in the URL instead of using the accept headers.
#
require 'rest-client'
require 'json'