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
module Colors
def colorize(text, color_code)
"\033[#{color_code}m#{text}\033[0m"
end
{
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
# Vista
a href="/services/jobs/new" data-behavior="add_service"
# Routes
get '/services/:root/new', to: 'services#new'
# Controller
def new
render partial: "services/new_#{params[:root]}"
end
li.score
.box-left
.box-line
- if service.premium?
i.icon-star.premium-service
span = service.title
.box-line
span Add a Comment
module Checkout::Base
extend ActiveSupport::Concern
included do
expose(:cc_dummy_data) { cc_data }
respond_to :json
end
def create
build_resource
(function($) {
"use strict"
awcp.behaviors.checkout = function(container) {
var behavior = {
init: function() {
behavior.submitBtn = $('button.btn.btn-default');
behavior.addClickListener();
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');
# 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
def search_results_for(attributes)
rtn = []
attempt = 1
while rtn.empty? && attempt <= 3
rtn = index.search(attributes, attempt)
attempt += 1
end
rtn
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);
<!-- Sin Alias -->
<div ng-controller="CustomersController">
<ul>
<li ng-repeat="customer in customers">
{{ customer.name }}
</li>
</ul>
</div>
<script>