This file contains hidden or 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
| ➜ ~ irb | |
| irb(main):001:0> class MyClass | |
| irb(main):002:1> def one | |
| irb(main):003:2> def two | |
| irb(main):004:3> 'hello' | |
| irb(main):005:3> end | |
| irb(main):006:2> end | |
| irb(main):007:1> end | |
| => nil | |
| irb(main):008:0> MyClass.instance_methods(false).grep /one/ |
This file contains hidden or 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
| var targetUsername = 'ccc'; | |
| var jsons = $("#downloaded").val().split("\n"); | |
| jsons = $.map(jsons, function (json, i) { | |
| json = JSON.parse(json); | |
| if (json.username === targetUsername) { | |
| return {"key": json.username, "count": 1, "like": json.like} | |
| } else { | |
| return null; | |
| } | |
| }); |
This file contains hidden or 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
| var targetUsername = 'ccc'; | |
| var jsons = $("#downloaded").val().split("\n"); | |
| jsons = $.map(jsons, function (json, i) { | |
| json = JSON.parse(json); | |
| if (json.username === targetUsername) { | |
| return {"key": json.username, "count": 1, "like": json.like} | |
| } else { | |
| return null; | |
| } | |
| }); |
This file contains hidden or 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
| irb(main):001:0> user = User.last | |
| User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 | |
| => #<User id: 2, email: "[email protected]", crypted_password: "$2a$10$zP5NtJOkczDUJmqwpaBK6u1dsKLReTcRW7TA5QubCn.m...", salt: "AJ7sa5TqToMfZxnkxPMn", created_at: "2012-10-01 05:20:41", updated_at: "2012-10-01 05:20:41", remember_me_token: nil, remember_me_token_expires_at: nil, reset_password_token: nil, reset_password_token_expires_at: nil, reset_password_email_sent_at: nil> | |
| irb(main):002:0> user.created_at | |
| => Mon, 01 Oct 2012 05:20:41 UTC +00:00 | |
| irb(main):003:0> user.created_at.class | |
| => ActiveSupport::TimeWithZone | |
| irb(main):004:0> user.created_at_before_type_cast | |
| => "2012-10-01 05:20:41.811503" | |
| irb(main):005:0> user.created_at_before_type_cast.class |
This file contains hidden or 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
| ➜ ~ cat ex.rb | |
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| class C | |
| attr_accessor :password, :secret | |
| def password=(pw) | |
| @password = pw | |
| @secret = @password.reverse |
This file contains hidden or 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
| # -*- encoding: utf-8 -*- | |
| class Bar | |
| end | |
| class Baz | |
| end | |
| class Foo < Bar | |
| end |
This file contains hidden or 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
| source :rubygems | |
| gem 'mappie', github: 'mizoR/mappie' |
This file contains hidden or 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
| macaroni --recipe my_recipe.rb --target news |
This file contains hidden or 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
| # -*- coding: utf-8-*- | |
| # exec: macaroni --recipe path/to/macaroni_with_twitter.rb --target tweet_search | |
| # gem dependency: `mizoR/macaroni`, `sferik/twitter` | |
| require 'twitter' | |
| include Macaroni::Plugin | |
| pipe :tweet_search, :data => Twitter do | |
| plug Filter::Configure do |config| |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| # -*- coding: utf-8 -*- | |
| require 'csv' | |
| require 'optparse' | |
| class NilClass | |
| def width | |
| 0 | |
| end |
OlderNewer