This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module M | |
def test | |
puts "test" | |
end | |
end | |
class X | |
include M | |
def test | |
puts "instance" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7.times do | |
ListMixin.create! | |
end | |
assert ListMixin.first.first? | |
assert ListMixin.last.last? | |
assert !ListMixin.last.first? | |
assert !ListMixin.first.last? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Regular expression for removing blank lines from a text: | |
#Replace this regex | |
/(\s+)^\r?\n?$(\s+)/mix | |
# With | |
$2 # The second match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
# gradual engagement is needed, to allow admin creation of users | |
# users should create authorization data only when they need to | |
# access some system feature that requires authentication | |
# So ... our gradual engagement scheme for authlogic: | |
# 1. admin creates user, setting only name and phone number (required) | |
# admin may set email address (optional) | |
# 2. user is sent email invitation with link to activate their account | |
# admin can re-send email at user's request | |
# 3. user sets login and password/password_confirmation using activation form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Barby | |
class SwanandRmagickOutputter < RmagickOutputter | |
register :to_jpg_2 | |
def to_jpg_2(*a) | |
to_blob('jpg', *a) | |
end | |
#Returns a string containing a JPEG image | |
def to_blob(format, *a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2012-03-29T10:25:10+00:00 app[app.1]: #bangalore-ruby <keyword> tweet - Returns a link to a tweet about <keyword> | |
2012-03-29T10:25:10+00:00 app[app.1]: <travis me> sferik/rails_admin - Returns the build status of https://github.com/sferik/rails_admin | |
2012-03-29T10:25:10+00:00 app[app.1]: <user> is a badass guitarist - assign a role to a user | |
2012-03-29T10:25:10+00:00 app[app.1]: <user> is not a badass guitarist - remove a role from a user | |
2012-03-29T10:25:10+00:00 app[app.1]: Find the build status of an open-source project on Travis | |
2012-03-29T10:25:10+00:00 app[app.1]: animate me <query> - The same thing as `image me`, except adds a few | |
2012-03-29T10:25:10+00:00 app[app.1]: convert me <expression> to <units> - Convert expression to given units. | |
2012-03-29T10:25:10+00:00 app[app.1]: help <query> - Displays all help commands that match <query>. | |
2012-03-29T10:25:1 | |
0+00:00 app[app.1]: help - Displays all of the help commands that bangalorehubot knows about. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HookMethodMissing | |
def method_missing(name, *args, &block) | |
puts name | |
super | |
end | |
end | |
class A | |
extend HookMethodMissing | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Open an irb (or pry) session preloaded with this gem" | |
task :console do | |
begin | |
require 'pry' | |
gem_name = File.basename(Dir.pwd) | |
sh %{pry -I lib -r #{gem_name}.rb} | |
rescue LoadError => _ | |
sh %{irb -rubygems -I lib -r #{gem_name}.rb} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javax.servlet.jsp.JspException: No bean found for attribute key WelcomeNote | |
at org.apache.struts.taglib.template.InsertTag.doEndTag(InsertTag.java:133) | |
at booking._0002fbooking_0002fplanner_0002ejspplanner_jsp_0._jspService(_0002fbooking_0002fplanner_0002ejspplanner_jsp_0.java:937) | |
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126) | |
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) | |
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:174) | |
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:274) | |
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:387) | |
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) | |
at com.broadvision.servlet.ServletContainer.service(ServletContainer.java:415) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns fourclojure.sequs-112) | |
;; https://www.4clojure.com/problem/112 | |
(declare sequs reducer) | |
(defn flatsum [v] (apply + (flatten v))) | |
(defn present? [_ el] (seq el)) |
OlderNewer