Skip to content

Instantly share code, notes, and snippets.

benoitr

Block or report user

Report or block benoitr

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 AccountKit.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1">
<title>Accountkit</title>
</head>
<body>
@benoitr
benoitr / simple_form_mdl_wrappers.rb
Created Oct 16, 2016 — forked from anonymous/simple_form_mdl_wrappers.rb
Material Design Lite wrappers for Simple Form
View simple_form_mdl_wrappers.rb
# Simple wrappers for Material Design Lite text fields to use with SimpleForm (Rails)
SimpleForm.setup do |config|
config.wrappers :mdl_field, tag: 'div', class: 'mdl-textfield mdl-js-textfield', error_class: 'mdl-textfield__error' do |b|
b.use :html5
b.use :input, class: 'mdl-textfield__input'
b.use :label, class: 'mdl-textfield__label'
end
View gist:84b631dbd162ed5c550844a44850a68f
git clone <repo-address>
git tag -l
git checkout <tag-name>
git branch -D master
git checkout -b master
View gist:5f497b6a3e6f86de83a8
/Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/test/unit.rb:199:in `block in non_options': file not found: db:prepare_template (ArgumentError)
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/test/unit.rb:178:in `map!'
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/test/unit.rb:178:in `non_options'
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/test/unit.rb:237:in `non_options'
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/test/unit.rb:58:in `process_args'
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1073:in `_run'
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1066:in `run'
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/test/unit.rb:27:in `run'
from /Users/benoit/.rbenv/versions/2.1.0/lib/ruby/2.1.0/test/unit.rb:780:in `run'
View gist:be77908cf9012d2195ba
class Admin::ResourceController < Admin::BaseController
before_action :load_resource
def index
respond_with @collection
end
def edit
respond_with(:admin, @object)
end
View business_hours.rb
require "time"
require "date"
class Date
def to_time
Time.local(year, month, day)
end
end
class Time
View gist:e5fa43703218f7fead5c
#!/bin/sh
read -r -p "Confirm deployment to PRODUCTION? Type 'yes' to continue " response
if [[ $response == "yes" ]]
then
# Precompile assets and commit to github
bundle exec rake assets:precompile RAILS_ENV=production
git add .
git commit -m 'recompiling assets'
git push origin master
@benoitr
benoitr / 0_reuse_code.js
Created May 20, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View README.markdown

Nestable, sortable and dragable categories:

In the project I'm working on we wanted to have a Category model which we wanted to be nestable. But we also liked the user to have a draggable interface to manage and rearrange the order of his categories. So we chose awesome_nested_set for the model and jQuery.nestedSortable for the UI.

It took me some time to arrange things to work properly so I wanted to share my work in case it helps anybody.

Before beginning

you might want to take a look at a demo app

  1. go to: http://awesomenestedsortable.heroku.com/groups/
  2. click in show of any group
View application_helper.rb
module ApplicationHelper
# ==== Examples
# glyph(:share_alt)
# # => <i class="icon-share-alt"></i>
# glyph(:lock, :white)
# # => <i class="icon-lock icon-white"></i>
def glyph(*names)
content_tag :i, nil, class: names.map{|name| "icon-#{name.to_s.gsub('_','-')}" }
end
You can’t perform that action at this time.