Skip to content

Instantly share code, notes, and snippets.

José Valim josevalim

Block or report user

Report or block josevalim

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:3408772
josevalim / sample output
Created May 24, 2012 — forked from alco/sample output
Updated Elixir chat demo
View sample output
defmodule Chat.Client do
# In all of the following functions 'server' stands for the server's pid
def join(server) do
send server, :join
def say(server, message) do
send server, { :say, message }
josevalim / elixir.rb
Created Mar 3, 2012 — forked from huffman/elixir.rb
Elixir Homebrew recipe
View elixir.rb
# Install this recipe with:
# brew install
require 'formula'
class ErlangInstalled < Requirement
def message; <<-EOS.undent
Erlang is required to install.
You can install this with:
View index.html.erb
<% @widgets.each do |widget| %>
<p><%= %></p>
<% end %>
josevalim / index.erb
Created Dec 13, 2011 — forked from rafacv/index.erb
Code to get a hanging POST request on Windows using WEBRICK.
View index.erb
<script src=""></script>
$(function () {
$("#myb").click(function () {
url: "/showme",
type: "POST",
data: {nome: "Jose", sobrenome: "Valim"},
View gist:1012168
module UnicornPowers
def fire_super_ray_beam
module TomCruise
mixin UnicornPowers
def ray_beam_power
View application_controller.rb
# How to give your devise controllers all the same layout (e.g. "authentication" below)
class ApplicationController < ActionController::Base
layout :setup_layout
def setup_layout
devise_controller? ? "authentication" : "application"
View to_xml
# 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>
View gist:356909
Warden::Strategies.add(:openid) do
def valid?
def authenticate!
if resp = env[Rack::OpenID::RESPONSE] "Attempting OpenID auth: #{env["rack.openid.response"].inspect}"
case resp.status
when :success
View snippet.rb
# 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
You can’t perform that action at this time.