“Before I speak, I have something important to say” —Groucho Marx Tech and Random stuff by Elia Schito
Don't wanna be here? Send us removal request.
Text
Past and Future of Ruby and Rails
As a sad orphan of railsapi.com I'm proud to present you valuable links to ruby and rails documentation in SDoc format:
Searchable Ruby 2.0 API documentation
http://elia.github.io/railsapi.com/public/doc/ruby-v2.0/
Searchable Rails 3.2 API documentation
http://elia.github.io/railsapi.com/public/doc/rails-v3.2/
1 note
·
View note
Text
Autocomplete "git" as "g"
For all you lazy Git bums, here's how you can type "g" got "git" and still have autocompletion (paste into your ~/.bash_profile or .dotfiles system):
alias g='git' complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \ || complete -o default -o nospace -F _git g
2 notes
·
View notes
Text
Let jRuby and Pow!™ be happy together
Turns out that Pow! won't support jRuby anytime soon but the trick described in josh/nack#32 actually works, so rollup your shirt's sleeves! Go open node_modules/nack/lib/nack/server.rb inside ~/Library/Application Support/Pow/Current and replace sock.close_read on line 132 with:
# WAS: sock.close_read begin sock.close_read rescue IOError raise unless RUBY_ENGINE == 'jruby' end
Happy hacking!
3 notes
·
View notes
Text
Get back Rails backtrace links on Safari 6
If you're back to Safari and want your clickable Rails backtraces here's the solution: [**Download RailsnStacktracenlinks.safariextz**](http://cl.ly/3q0S2B004607) Thanks to [http://kangoextensions.com](http://kangoextensions.com) that made supereasy transform a userscript into a Safari extension. ![Links again!](http://f.cl.ly/items/1I1S0y3x0H3Z3u2A0g0h/Schermata%202012-09-29%20alle%2011.12.55%20pm.png)
0 notes
Text
[slides] Rails views for the OO-savvy Rubyist
Rails OO views from Elia Schito
note: transitions and music are lost with slideshare, but you can get an idea of them in this video:
0 notes
Text
I'll speak at RubyDay.it tomorrow!
I was asked to write about the talk I'll give tomorrow at **[RubyDay.it](http://rubyday.it)**. Without giving away too much here's a post I wrote some time ago about [`@instance_variables` usage in Rails implementation](http://elia.schito.me/post/17547757285/another-reason-to-avoid-instance-variables-into-rails). Last I add a promise: _it will be fun!_ _Cross posted from [MIKAMAYHEM](http://dev.mikamai.com)_
0 notes
Text
“Use Node.js FOR SPEED” — @RoflscaleTips
So I obeyed, and wrote the `opal` NPM package, this way, finally, Rails and [`opal-rails`][1] are no longer necessary. Here's my first node app:
server = Server.new 3000 server.start do [200, {'Content-Type' => 'text/plain'}, ["Hello World!\n"]] end
For it I had to write the `Server` class:
class Server def initialize port @http = `require('http')` @port = port end def start &block %x{ this.http.createServer(function(req, res) { var rackResponse = (block.call(block._s, req, res)); res.end(rackResponse[2].join(' ')); }).listen(this.port); } end end
Put them in `app.opal` and then start the server:
$ npm install -g opal # <<< install the NPM package first! $ opal-node app
![The running app][2] ### YAY! now I can roflSCALE all of my RAils apps!!1 [1]: http://elia.schito.me/post/24087273859/stop-writing-javascript-and-get-back-to-ruby [2]: http://f.cl.ly/items/352N3A2U0c013I391i0Q/Schermata%2006-2456088%20alle%206.18.09%20pm.png
5 notes
·
View notes
Text
Stop writing JavaScript and get back to Ruby!
Remeber that feeling that you had after having tried CoffeeScript getting back to a project with plain JavaScript and felt so constricted?
Well, after re-writing a couple of coffee classes with OpalRuby I felt exactly that way, and with 14.9KB of footprint (min+gz, jQuery is 32KB) is a complete no brainer.
So let's gobble up our first chunk of code, that will salute from the browser console:
puts 'hi buddies!'
You wonder how that gets translated?
Fear that it will look like this?
'egin',cb='bootstrap',u='clear.cache.gif',z='content',bc='end',lb='gecko',mb='g cko1_8',yb='gwt.hybrid',xb='gwt/standard/standard.css',E='gwt:onLoadErrorFn',B= 'gwt:onPropertyErrorFn',y='gwt:property',Db='head',qb='hosted.html?hello',Cb='h ref',kb='ie6',ab='iframe',t='img',bb="javascript:''",zb='link',pb='loadExternal Refs',v='meta',eb='moduleRequested',ac='moduleStartup',jb='msie',w='name',gb='o pera',db='position:absolute;width:0;height:0;border:none',Ab='rel',ib='safari', rb='selectingPermutation',x='startup',m='hello',Bb='stylesheet',ob='unknown',fb ='user.agent',hb='webkit';var fc=window,k=document,ec=fc.__gwtStatsEvent?functi on(a){return fc.__gwtStatsEvent(a)}:null,zc,pc,kc,jc=l,sc={},Cc=[],yc=[],ic=[], vc,xc;ec&&ec({moduleName:m,subSystem:x,evtGroup:cb,millis:(new Date()).getTime( ),type:nb});if(!fc.__gwt_stylesLoaded){fc.__gwt_stylesLoaded={}}if(!fc.__gwt_sc riptsLoaded){fc.__gwt_scriptsLoaded={}}function oc(){var b=false;try{b=fc.exter
Nope! it's Chuck Testa
(function() { return this.$puts("hi buddies!") }).call(Opal.top);
But it will be obviously a mess to integrate it with existing javascript!!1
Let's how to add #next and #prev to the Element class:
class Element def next(selector = '') element = nil `element = jQuery(this.el).next(selector)[0] || nil;` Element.new element if element end end
But I'm on Rails!
Here you served:
gem 'opal-rails'
Which il provide you a requirable libraries for application.js
//= require opal //= require rquery
and the .opal extension for your files
# app/assets/javascripts/hi-world.js.opal puts "G'day world!"
A template handler:
# app/views/posts/show.js.opal.erb Element.id('<%= dom_id @post %>').show
and a Haml filter!
-# app/views/posts/show.html.haml %article= post.body %a#show-comments Display Comments! .comments(style="display:none;") - post.comments.each do |comment| .comment= comment.body :opal Document.ready? do Element.id('show-comments').on :click do Element.find('.comments').first.show false # aka preventDefault end end
3 notes
·
View notes
Link
Use dimensions by @sstephenson to add automatic images size and improve browser rendering
UPDATE: I just released the dimensions-rails gem which adds default width and height to the image_tag helper!
7 notes
·
View notes
Text
Open the current url from TextMate
Whenever you're within some text in TextMate you can see the urls properly underlined. Today I finally (and accidentally) discovered how to open those urls in the browser.
The command is ⌅ and on my macbook can be reached by using together fn and ⏎.
Now that I know it I can start implementing the lynx bundle!
6 notes
·
View notes
Photo
![Tumblr media](https://64.media.tumblr.com/tumblr_m17eryOpYD1qzaszdo1_540.jpg)
Jedi training on Cesano Boscone (the planet)
2 notes
·
View notes
Text
Another reason to avoid instance variables into Rails controllers? /2
They have an insane implementation:
(still in rails head)
# Define some internal variables that should not be propagated to the view. self.protected_instance_variables = [ :@_status, :@_headers, :@_params, :@_env, :@_response, :@_request, :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout ]
3 notes
·
View notes
Text
Another reason to avoid instance variables into Rails controllers?
They can't be deprecated. (at least AFAIK)
Now go, and add gem 'decent_exposure' to your Gemfile.
13 notes
·
View notes
Text
Awkward Rails 2 routes
Don't use parenthesis to mark a parameter as optional in a Rails 2 route
3 notes
·
View notes
Text
Set subdomain in Rails 3 request specs
Every request spec runs inside an Integration::Session hence just add:
before { host! "mysubdomain.#{host}" }
This of course works for Rails3+Rspec2.
14 notes
·
View notes