Skip to content

Instantly share code, notes, and snippets.

View darkofabijan's full-sized avatar

Darko Fabijan darkofabijan

View GitHub Profile
class Longtail
attr_accessor :model
attr_accessor :field
def initialize(options)
@model = options[:model]
@field = options[:field]
end
def fetch
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end
class Api::V2::MunicipalitiesController < Api::V2::BaseController
def index
municipalities = Municipality.find_all_for_api
@municipalities = municipalities.collect { |m| {:id => m.id, :name => m.name} }
render_json(@municipalities)
end
end
@darkofabijan
darkofabijan / user.rb
Created February 22, 2012 12:17 — forked from miloshadzic/user.rb
class User < ActiveRecord::Base
def find_form(id)
company.forms.find(id)
end
end
class User < ActiveRecord::Base
def forms
Form.where(:company => company)
end
def find_form(id)
forms.find(id)
end
end
sudo apt-get install mercurial
hg clone https://vim.googlecode.com/hg/ vim
cd vim
./configure --enable-rubyinterp --enable-gui=no
make
sudo make install
@darkofabijan
darkofabijan / redis.markdown
Created October 25, 2012 10:28 — forked from eskim/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

➜ vSync git:(sharing) be rake stats
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 1446 | 1101 | 33 | 170 | 5 | 4 |
| Helpers | 297 | 239 | 0 | 29 | 0 | 6 |
| Models | 677 | 491 | 15 | 84 | 5 | 3 |
| Libraries | 1971 | 1551 | 41 | 144 | 3 | 8 |
| Model specs | 559 | 396 | 0 | 1 | 0 | 394 |
| Controller specs | 951 | 694 | 0 | 6 | 0 | 113 |

Typography

Headings

Headings from h1 through h6 are constructed with a # for each level:

# h1 Heading
## h2 Heading
### h3 Heading
defmodule MyApp.Router do
use Phoenix.Router
namespace MyApp.Controllers do
get "restaurants/:id", Restaurants, :show, as: :restaurant
resources :images
resources :users, Accounts