Skip to content

Instantly share code, notes, and snippets.

View edison's full-sized avatar
🏠
Working from home

Edison Machado edison

🏠
Working from home
View GitHub Profile
@edison
edison / controller.rb
Created January 28, 2015 01:11
Devise Sessions Controller for Ajax
class Website::SessionsController < ::Devise::SessionsController
respond_to :js
layout false
# POST /resource/sign_in
def create
self.resource = warden.authenticate(auth_options)
if resource && resource.active_for_authentication?
sign_in(resource_name, resource)
@edison
edison / gist:980015
Created May 19, 2011 01:58
Sass::SyntaxError when using CSS "alpha-opacity" property
Sass::SyntaxError in Main/cockpit#index
Showing /Users/edison/Sites/beta.foco/app/views/layouts/application.html.haml where line #8 raised:
Invalid CSS after "...: alpha(opacity": expected comma, was ":0);"
Extracted source (around line #8):
5: %meta{'http-equiv' => 'Content-language', 'content' => I18n.locale}
6: %meta{'http-equiv' => 'Content-Type', 'content' => 'text/html; charset=utf-8'}
@edison
edison / gist:980092
Created May 19, 2011 02:53
pjax syntax error
edison$ rails s
/Users/edison/.rvm/gems/ruby-1.8.7-p334/gems/pjax-rails-0.1.1/lib/pjax-rails.rb:1:in `require': /Users/edison/.rvm/gems/ruby-1.8.7-p334/gems/pjax-rails-0.1.1/lib/pjax.rb:5: syntax error, unexpected '>' (SyntaxError)
layout ->(c) { pjax_request? ? false : 'application' }
^
/Users/edison/.rvm/gems/ruby-1.8.7-p334/gems/pjax-rails-0.1.1/lib/pjax.rb:5: syntax error, unexpected '{', expecting kEND
layout ->(c) { pjax_request? ? false : 'application' }
^
/Users/edison/.rvm/gems/ruby-1.8.7-p334/gems/pjax-rails-0.1.1/lib/pjax.rb:5: syntax error, unexpected '}', expecting kEND
/Users/edison/.rvm/gems/ruby-1.8.7-p334/gems/pjax-rails-0.1.1/lib/pjax.rb:10: odd number list for Hash
new_url = url_for(url ? url : { action: action })
@edison
edison / pjax.rb
Created May 19, 2011 07:27
Pjax with ruby 1.8.7
module Pjax
extend ActiveSupport::Concern
included do
layout lambda {|c| c.pjax_request? ? false : 'application' }
end
private
def redirect_pjax_to(action, url = nil)
new_url = url_for(url ? url : { :action => action })
@edison
edison / log-2011-05-19
Created May 20, 2011 01:12
encoding error Rails 3.1
edison$ rails s
=> Booting WEBrick
=> Rails 3.1.0.beta1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-05-19 22:07:41] INFO WEBrick 1.3.1
[2011-05-19 22:07:41] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.7.0]
[2011-05-19 22:07:41] INFO WEBrick::HTTPServer#start: pid=4975 port=3000
Error during failsafe response: "\xC3" from ASCII-8BIT to UTF-8
/Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.beta1/lib/active_support/buffered_logger.rb:104:in `write'
@edison
edison / error_log
Created May 26, 2011 08:02
undefined method `delegate_template_exists?'
edison$ rails s
=> Booting Mongrel
=> Rails 3.1.0.rc1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:16:in `alias_method': undefined method `delegate_template_exists?' for class `ActionView::Base' (NameError)
from /Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:16:in `<class:Base>'
from /Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:12:in `<module:ActionView>'
from /Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:11:in `<top (required)>'
@edison
edison / tokitozuska.rb
Created November 14, 2011 03:11
Tokitozuska
# RIKUTATAMO, KIRIN KA TOKITOZUSKA.
# KI MIKATO CHISHIKATOARITAKACHIKU KATOFUCHIRIKITOJI FUMODO MEIKATOCHI.
# KADOCHIRIMOSHI: KUTEKIARIMOTO RINKAMIRIKATEMO.
class Tokitozuska
@@mirikashiari = {
"a" => "ka",
"b" => "zu",
"c" => "mi",
"d" => "te",
@edison
edison / file_resource.rb
Created January 24, 2012 18:35 — forked from watson/file_resource.rb
Example Rails model using Paperclip and storing files on S3. This shows how to correctly set a custom header and saving the file in the correct location after it has been directly uploaded to from the users browser.
class FileResource < ActiveRecord::Base
has_attached_file :attachment,
:storage => :s3,
:bucket => ENV['S3_BUCKET'],
:s3_credentials => { :access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET'] },
:path => 'files/:id/:filename',
:url => '/files/:id/:filename'
@edison
edison / will_paginate.rb
Created February 8, 2012 03:38 — forked from isaacbowen/will_paginate.rb
extends will_paginate to play well with Twitter's Bootstrap
# config/initializers/will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
// server
var net = require("net")
, server
;
server = net.createServer(function(socket){
// socket.end("bye\n");
socket.on("connect", function(){
console.log("conectou\n");