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
%%%---------------------------------------------------------------------- | |
%%% File : time_server.erl | |
%%% Author : Claes Wikstrom <klacke@erix.ericsson.se> | |
%%% Purpose : | |
%%% Created : 3 Nov 1998 by Claes Wikstrom <klacke@erix.ericsson.se> | |
%%%---------------------------------------------------------------------- | |
-module(time_server). | |
-author('klacke@erix.ericsson.se'). |
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
require 'active_record' | |
require 'logger' | |
ActiveRecord::Base.establish_connection(ENV["DATABASE_URL"]) | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
# Models | |
require_relative 'models/user' |
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 MArray < Array | |
def self.wrap(value) | |
new([value]) | |
end | |
def self.empty | |
new([]) | |
end | |
def +(other) |
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 Base62 | |
BASE62_ALPHABET = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a | |
def encode(str) | |
packed_int = str.unpack('C*').each_with_index.reduce(0){|r,(x,i)| r + (x << 8*i) } | |
return '0' if packed_int == 0 | |
s = '' | |
while packed_int > 0 |
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 ChatChannel < ActionChannel::Base | |
# join is triggered on user connect | |
def join(channel, message) | |
puts "JOIN #{channel}" | |
# reply messages are sent only to the user invoking the action | |
reply "user:welcome", salute: "Welcome to the channel #{message['username']}!!!" | |
# broadcast messages are sent to all the users connected to the channel | |
broadcast "user:entered", username: message["username"] |
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
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
gem "tzinfo" | |
# Let's use thin |
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
require 'active_record' | |
require 'active_record/fixtures' | |
class MiniTest::Spec | |
ActiveRecord::Base.establish_connection | |
ActiveRecord::Migration.check_pending! | |
include ActiveRecord::TestFixtures | |
alias :method_name :name if defined? :name |
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
#!/usr/bin/python | |
import time | |
print (time.strftime("%d/%m/%G")) | |
print (time.strftime("%d/%m/%Y")) |
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
diff --git a/lib/active_model/serializer/adapter.rb b/lib/active_model/serializer/adapter.rb | |
index 8eacc39..f0a8257 100644 | |
--- a/lib/active_model/serializer/adapter.rb | |
+++ b/lib/active_model/serializer/adapter.rb | |
@@ -17,13 +17,7 @@ module ActiveModel | |
end | |
def to_json(options = {}) | |
- result = serializable_hash(options) | |
- |
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
diff --git a/lib/active_model/serializer/adapter.rb b/lib/active_model/serializer/adapter.rb | |
index 8eacc39..f0a8257 100644 | |
--- a/lib/active_model/serializer/adapter.rb | |
+++ b/lib/active_model/serializer/adapter.rb | |
@@ -17,13 +17,7 @@ module ActiveModel | |
end | |
def to_json(options = {}) | |
- result = serializable_hash(options) | |
- |