Skip to content

Instantly share code, notes, and snippets.

View tagrudev's full-sized avatar

Todor Grudev tagrudev

View GitHub Profile
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: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';
describe 'ambitions spec' do
it 'should return true only the first time #YOLO' do
death.should be_true
end
end
Give me some Clojure:
> (empty? nil)
true
> nil
nil
> (nil? "")
false
> (empty? "")
true
>
@tagrudev
tagrudev / gist:4351631
Last active December 10, 2015 00:29 — forked from anonymous/gist:4351607
def create_report
if @inspection.type == 'RoutineInspection'
puts "---CR> CREATING ROUTINE INSPECTION REPORT"
pdf = routine_inspection_generic
else
puts "---CR> CREATING INGOING INSPECTION REPORT"
thread = Thread.new do
pdf = ingoing_inspection_nsw
end.join
end
str = (0...MAX_NUM).map { |n| n.en.numwords }.join.gsub(/ and /, "").gsub(/\W/, "")
NoMethodError: undefined method `en' for 0:Fixnum
@tagrudev
tagrudev / gist:4537658
Created January 15, 2013 10:04
link_to image + text
<%= link_to '#' do %>
hiii <%= image_tag('/images/menu-arrow-down.gif') %>
<% end %>
@tagrudev
tagrudev / Gemfile
Last active December 14, 2015 09:09 — forked from anonymous/Gemfile
source 'http://rubygems.org'
# source 'http://localhost:9292'
gemspec
group :test do
gem "simplecov", :require => false
gem "shoulda-matchers"
gem "shoulda-context"
gem "capybara-screenshot"
class PerspectivesController < ApplicationController
# GET /perspectives
# GET /perspectives.json
def index
@perspectives = Perspective.all
unless params['perspective']
@perspective = @perspectives.where(default: true).first || Perspective.new
else
@perspective = Perspective.new
end
2.0.0dev :015 > raw_params = {"layout"=>"layout_04", "zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]}
=> {"layout"=>"layout_04", "zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]}
2.0.0dev :016 > params = ActionController::Parameters.new(raw_params) => {"layout"=>"layout_04", "zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]}
2.0.0dev :017 > params.permit(:zone_ids => []) => {"zone_ids"=>["", "", "", "50e5a81a421aa977fa00000b"]}