Skip to content

Instantly share code, notes, and snippets.

View dbarrionuevo's full-sized avatar

Darío Barrionuevo dbarrionuevo

  • San Miguel de Tucumán
View GitHub Profile
# Which one is your preferred syntax?
# Indentation 1
class Dummy
def public_method
end
private
def private_method
end
class Validator
attr_reader :errors
def initialize(v1, v2)
@v1 = v1
@v2 = v2
@errors = []
end
def validate!
$(function() {
var len = 100;
var p = $("[data-id='truncate']");
if (p) {
var trunc = p.html();
if (trunc.length > len) {
trunc = trunc.substring(0, len);
trunc = trunc.replace(/\w+$/, '');
<!--
La consigna es llegar hasta la opción seleccionada en select.form-control,
pero partiendo desde el checkbox
-->
<div class="member-option member-no-signup">
<div class="member-checkbox">
<input data-behavior="add_membership" name="option" type="checkbox" value="">
</div>
<div class="member-content">
namespace :images do
namespace :portfolio do
desc "Reprocess PortfolioImage in order to calculate and save image dimensions"
task :generate_dimensions => [:environment] do
exceptions = []
failures = []
logger = ActiveSupport::BufferedLogger.new(Rails.root.join("log", "reprocess_portfolio.log"))
scope = User.sellers.is_published.where(:show_on_hdr => true)
if ids = ENV["ID"]
<!-- Sin Alias -->
<div ng-controller="CustomersController">
<ul>
<li ng-repeat="customer in customers">
{{ customer.name }}
</li>
</ul>
</div>
<script>
var NotificationsService = function () {
this.MAX_LEN = 10;
this.notificationsArchive = new NotificationsArchive();
this.notifications = [];
};
NotificationsService.prototype.push = function (notification) {
var newLen, notificationToArchive;
newLen = this.notifications.unshift(notification);
def search_results_for(attributes)
rtn = []
attempt = 1
while rtn.empty? && attempt <= 3
rtn = index.search(attributes, attempt)
attempt += 1
end
rtn
# No tiene sentido hacer tan verbosa la acción, no usa bien el respond_with
def create
user = User.new(user_params)
if user.save
render json: user, status: 201, location: [:api, user]
else
render json: { errors: user.errors }, status: 422
end
end
show_autocomplete: function (itemName, collection) {
$('.' + itemName).autocomplete({
source: function (request, response) {
var contains1, containsMatcher1, startsWith1, startsWithMatcher1, term;
term = $.ui.autocomplete.escapeRegex(request.term);
startsWithMatcher1 = new RegExp('^' + term, 'i');
startsWith1 = $.grep(collection, function (value) {
return startsWithMatcher1.test(value.label || value.value || value);
});
containsMatcher1 = new RegExp('\\b' + term, 'i');