Skip to content

Instantly share code, notes, and snippets.

View roalcantara's full-sized avatar
🤖
Don't Panic!

Rogério Rodrigues de Alcântara roalcantara

🤖
Don't Panic!
View GitHub Profile
@roalcantara
roalcantara / remove.sh
Created August 26, 2015 03:38
Remove all from pipe
locate foo | xargs rm -rf
@roalcantara
roalcantara / UserController.groovy
Last active August 27, 2015 09:49
Grails + Spock: Mocking Templates
package com.foo.controllers
class UserController {
def show(final String username) {
render template: 'greetings', model: [username:username]
}
}
@roalcantara
roalcantara / index.gsp
Last active August 27, 2015 14:28
Grails + Resource Plugin + SWF Files
<html>
<head>
<g:render template="/templates/main"/>
<title>Copy to Clipboard Using SWF!</title>
</head>
<body>
<r:script>
$(function() {
//place the swf in /web-app/ (i.e.: /web-app/swf/ZeroClipboard.swf)
//and use the r.resource tag
@roalcantara
roalcantara / _dish_form.html.erb
Last active August 29, 2015 13:58
Rails4 + Twitter Bootstrap checkbox + collection_check_boxes
<div class="form-group>
<%= f.label :ingredients %>
<%= f.collection_check_boxes :ingredient_ids, Ingredient.order(:name), :id, :name do |b|
b.label(class: "checkbox") { b.check_box + b.text }
end %>
</div>
@roalcantara
roalcantara / querying_not_and_order.rb
Created April 10, 2014 04:49
Rails4 > Querying: not in + order
Product.where.not(id:@order.products).order(:name)
@roalcantara
roalcantara / .bowerrc
Last active August 29, 2015 14:00
Rails 4.1 + Bower + Twitter Bootstrap 3 Glyphicons
{
"directory": "vendor/assets/bower"
}
@roalcantara
roalcantara / new.html.erb
Created June 4, 2014 09:33
Rails 4.1.0.rc2: Singleton resource + form_for
<!-- the only way that worked for me =\ -->
<%= form_for @foo, url:{action:'create'} do |f| %>
...
<% end %>
@roalcantara
roalcantara / products.rb
Created July 14, 2014 07:56
Factory Girl (4.4.0) + Paperclip (4.2.0)
#/spec/factories/products.rb
include ActionDispatch::TestProcess
FactoryGirl.define do
factory :product do
photo {fixture_file_upload 'spec/files/product.jpg', 'image/jpg'}
end
end
@roalcantara
roalcantara / address.rb
Created July 14, 2014 09:53
FactoryGirl + validate_presence_of + has_one
class Address < ActiveRecord::Base
belongs_to :user
end
@roalcantara
roalcantara / foo.js.coffee
Created December 29, 2014 07:13
Coffeescript class + jquery $.post example
window.App or= {}
class App.Foo
constructor:->
@$container = $('.container')
@bind()
bind:->
@$container.on 'click', '.btn.update', @update