Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am DefV on github.
* I am defv (https://keybase.io/defv) on keybase.
* I have a public key whose fingerprint is CF6C 837A FC61 A672 EB88 B14A 8C49 44CF C9C3 6768
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am DefV on github.
* I am defv (https://keybase.io/defv) on keybase.
* I have a public key whose fingerprint is CF6C 837A FC61 A672 EB88 B14A 8C49 44CF C9C3 6768
To claim this, I am signing this object:
def icon_link_to(name, link, options = {})
link_to link, options do
content_tag(:span, name) + content_tag(:i, '', class: "fa fa-#{options[:icon]}"
end
end
12:42 :: guinsly:: I'm trying to retrieve a content from another class. But it outputs nil :: https://gist.github.com/guinslym/06bb6bc108c9331e1ff0
12:42 :: jhass:: guinsly: is that your real code? or an example that reproduces? because class foo is invalid
12:43 :: shevy:: arup_r, http://stackoverflow.com/questions/543774/undef-why-would-you-want-to-undefine-a-method-in-ruby - but it seems as if people rarely need it
12:43 :: jhass:: also note that the @firstname outside a def is a different @firstname
12:43 :: jhass:: guinsly: ^
12:43 :: shevy:: I never needed undef, I did need undef_method (or actually... remove_method it was...)
12:43 :: guinsly:: jhass, this the realcode except class foo is name LoadFile
12:43 :: jhass:: why did you change it?
12:44 :: jhass:: but your issue is probably what I just said
12:44 :: apeiros:: weird indent. tabs mixed with spaces? o0
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This is a Vagrant configuration file. It can be used to set up and manage
# virtual machines on your local system or in the cloud. See http://downloads.vagrantup.com/
# for downloads and installation instructions, and see http://docs.vagrantup.com/v2/
# for more information and configuring and using Vagrant.
Vagrant.configure("2") do |config|
# Omnibus for chef install
config.omnibus.chef_version = :latest
@DefV
DefV / bench.rb
Created September 9, 2014 10:17
Bench
require 'benchmark'
n = 100_000_000
Benchmark.bm do |x|
x.report do
result = []
row = nil
n.times do |i|
row = i * 5
result << row
u = User.find(params[:id])
u.activities.last # Does a find(:last)
# Add something to the activities
u.activities.create!({:description => "List activities"})
u.activities.last # Fetches all activities of the user - Painfull when a user has 30000 activities
@DefV
DefV / gist:241852
Created November 24, 2009 12:52 — forked from pjaspers/gist:241847
require 'lingua/en/readability'
class Haiku
def initialize(text)
@report = Lingua::EN::Readability.new(text)
@used_words = Array.new
end
def get_most_used_words(words)
top_words = Array.new
words.sort{|a,b| a[1]<=>b[1]}.slice(words.length/2..words.length).each do |a|
class ApplicationController < ActionController::Base
protect_from_forgery
class << self
def responder *responders
if responders.any?
responder_class = Class.new(ActionController::Responder)
responders.each do |responder|
responder = responder.is_a?(Module) ? responder : "#{responder.to_s.classify}Responder".constantize
responder_class.send(:include, responder)
@DefV
DefV / gist:1018547
Created June 10, 2011 09:35
ruby 1.9.2-p180 patched zip failure
ruby-1.9.2-p180-patched :001 > (1..2).zip(1..2)
(irb):1: [BUG] Bus Error
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
-- control frame ----------
c:0027 p:---- s:0092 b:0092 l:000460 d:000460 CFUNC :next
c:0026 p:---- s:0090 b:0090 l:000085 d:000089 IFUNC
c:0025 p:---- s:0088 b:0088 l:000087 d:000087 CFUNC :each
c:0024 p:---- s:0086 b:0086 l:000085 d:000085 CFUNC :zip
c:0023 p:0014 s:0082 b:0082 l:001d18 d:000081 EVAL (irb):1