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
Expected: | |
[ | |
[{"a","b"},{"c","d"}], | |
[{"a1","b1"},{"c1","d1"}], | |
[{"a2","b2"},{"c2","d2"}] | |
] | |
Actual: |
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
defmodule Chat.Client do | |
# In all of the following functions 'server' stands for the server's pid | |
def join(server) do | |
send server, :join | |
end | |
def say(server, message) do | |
send server, { :say, message } | |
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
# Install this recipe with: | |
# brew install https://raw.github.com/gist/1968046/0302279edc972e9d147110bd69284d0e2becda41/elixir.rb | |
require 'formula' | |
class ErlangInstalled < Requirement | |
def message; <<-EOS.undent | |
Erlang is required to install. | |
You can install this with: |
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
<% @widgets.each do |widget| %> | |
<p><%= widget.name %></p> | |
<% 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
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script> | |
$(function () { | |
$("#myb").click(function () { | |
$.ajax({ | |
url: "/showme", | |
type: "POST", | |
data: {nome: "Jose", sobrenome: "Valim"}, |
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 UnicornPowers | |
def fire_super_ray_beam | |
self.ray_beam_power | |
end | |
end | |
module TomCruise | |
mixin UnicornPowers | |
def ray_beam_power |
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
# How to give your devise controllers all the same layout (e.g. "authentication" below) | |
class ApplicationController < ActionController::Base | |
layout :setup_layout | |
protected | |
def setup_layout | |
devise_controller? ? "authentication" : "application" | |
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
# note that last item is User class | |
a = [10, [20, 30, ["helo", "world"]], [1.2, 1.3], {:foo => :bar}, User] | |
puts a.to_xml | |
<?xml version="1.0" encoding="UTF-8"?> | |
<objects type="array"> | |
<object type="integer">10</object> | |
<object type="array"> | |
<object type="integer">20</object> |
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
Warden::Strategies.add(:openid) do | |
def valid? | |
!params["openid_identifier"].blank? | |
end | |
def authenticate! | |
if resp = env[Rack::OpenID::RESPONSE] | |
RAILS_DEFAULT_LOGGER.info "Attempting OpenID auth: #{env["rack.openid.response"].inspect}" | |
case resp.status | |
when :success |
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 "rack/openid" | |
require 'devise/strategies/base' | |
require 'uri' | |
module Devise | |
module Strategies | |
# Default strategy for signing in a user, based on openid | |
# Redirects to sign_in page if it's not authenticated | |
class OpenId < Warden::Strategies::Base | |
include Devise::Strategies::Base |