Skip to content

Instantly share code, notes, and snippets.

View Nerian's full-sized avatar

Gonzalo Rodríguez-Baltanás Díaz Nerian

View GitHub Profile
@lamp
lamp / quick_approve.js
Created October 18, 2017 21:24
Mark All Issues on codeclimate as wontfix
$('li[data-issue-status-name="wontfix"]').each((i, e) => { e.click() })
$('input[name="commit"]').each((i, e) => { e.click() })
@theCrab
theCrab / authentication.rb
Last active April 27, 2022 15:42
A Hanami Framework authentication based on JSON Web Tokens.
# lib/authentications/authentication.rb
# @api auth
# Authentication base class
#
module Authentication
def self.included(base)
base.class_eval do
before :authenticate!
expose :current_user
@sidonath
sidonath / flash.rb
Last active August 29, 2015 14:00
An implementation of flash feature on top of Lotus::Action::Session
# A basic Rails-like Flash implementation built upon Lotus::Action::Session.
# Based upon Rack-flash:
# https://github.com/nakajima/rack-flash
module Flash
def self.included(action)
action.class_eval do
# We rely on features provided by Lotus::Action::Session so let's include
# it right here
include Lotus::Action::Session
@SteveBenner
SteveBenner / unbrew.rb
Last active January 3, 2024 01:44
Homebrew uninstall script
#!/usr/bin/env ruby
#
# CLI tool for locating and removing a Homebrew installation
# http://brew.sh/
#
# Copyright (C) 2014 Stephen C. Benner
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@cavalle
cavalle / cohesion-and-big-models.md
Last active December 11, 2015 21:09
Cohesion and Big ActiveRecord Models

Cohesion and Big ActiveRecord Models

One of the problems of big ActiveRecord models is their low cohesion. In Rails we group behaviour around the entities of the domain we're modelling. If we use only ActiveRecord models for that, we'll probably end up with classes full of actions, in most cases, completely unrelated to each other (except for the fact that they act on the same domain entity).

To illustrate the issue let's imagine a big Post AR model of a blog application. In this app, users can add tags to their posts. Since this is the only class with this ability, I decide to put the related logic in the Post model itself. For this, presumably at the beginning of the file, I write a couple of has_many entries for tags and taggings. Then, fifty lines below, along with the rest of scopes, I add one more to find posts by tag name. A couple of hundred lines later, I put a virtual attribute tag_list which will be used to update the associations from a string of tag names separated by commas. Fin

@equivalent
equivalent / README.md
Last active December 16, 2021 16:34
String "false" to_bool ... or how to convert Rails/SimpleForm radio buttons to boolean

This gist was writen in 2012 and it was solving specific problem in Rails & SimpleForm. Some fellow developers were pointing out this may be out dated concept. That's why I advise everyone to read comment section bellow to have a full grasp of alternative solutions

other sources that may be helpful to understand why this may not be best idea:

@barryvdh
barryvdh / Example html
Created June 6, 2012 13:11
Sticky Footer (Less)
<div class="wrapper">
<div class="container">
<header>
</header>
<div id="content">
</div>
</div>
<div class="footer-push"></div>
@gudbergur
gudbergur / README.markdown
Created February 19, 2012 23:49
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@visnup
visnup / Screen shot 2011-02-07 at 4.37.04 PM.png
Created February 8, 2011 00:37
# trippy mongodb colorized logging by statement type
Screen shot 2011-02-07 at 4.37.04 PM.png