Skip to content

Instantly share code, notes, and snippets.

View tagrudev's full-sized avatar

Todor Grudev tagrudev

View GitHub Profile
Give me some Clojure:
> (empty? nil)
true
> nil
nil
> (nil? "")
false
> (empty? "")
true
>
describe 'ambitions spec' do
it 'should return true only the first time #YOLO' do
death.should be_true
end
end
@tagrudev
tagrudev / gist:4276467
Created December 13, 2012 13:46
Add custom fonts to your rails application
##
Lets say we have YoloFont.otf
1. We add it to vendor/assets/fonts/ folder
2. Me personaly creates a file named fonts.css.scss in app/assets/stylesheets
In it I have
@font-face{
font-family: 'YoloFont';
def get_model_name(item)
item.class.to_s == Car.to_s ? item.content.class.to_s : item.class.to_s
end
@tagrudev
tagrudev / gist:4215549
Created December 5, 2012 13:35
Check this out
[1] pry(#<Docushin::CollectionsController>)> @data[:id].class
=> String
[2] pry(#<Docushin::CollectionsController>)> @data[:id]
=> "9c52e7c86961d940906a65663d3649dc"
[4] pry(#<Docushin::CollectionsController>)> @data[:id].to_yaml
=> "--- 9c52e7c86961d940906a65663d3649dc\n...\n"
[5] pry(#<Docushin::CollectionsController>)> @data[:id].to_yaml
=> "--- !binary |-\n OWM1MmU3Yzg2OTYxZDk0MDkwNmE2NTY2M2QzNjQ5ZGM=\n"
[6] pry(#<Docushin::CollectionsController>)>
@tagrudev
tagrudev / gist:4215517
Created December 5, 2012 13:29
Where does this !binary comes from
[3] pry(#<Docushin::CollectionsController>)> @data[:id]
=> "4d696868a047e668b491fb43aebd2fc4"
[4] pry(#<Docushin::CollectionsController>)> @data[:id].to_yaml
=> "--- !binary |-\n NGQ2OTY4NjhhMDQ3ZTY2OGI0OTFmYjQzYWViZDJmYzQ=\n"
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../spec/dummy/config/environment", __FILE__)
require 'rubygems'
require 'bundler/setup'
require 'docushin'
require 'pry'
module ApplicationHelper
def cp(*paths)
paths.each do |path|
#do something
end
end
end
describe 'update markdown file' do
it 'should update specified attributes' do
route.save
route.updated_at.should == File.mtime(File.join(route.base, "#{route.file_name}.md")).to_i
end
end
class Docushin::CollectionsController < ActionController::Base
layout 'docushin'
def index
@content = File.read(File.join(Rails.root, "doc", "docushin", "collections.yml")) rescue []
@sets = @content.nil? ? nil : YAML.load(@content)
end
end