Skip to content

Instantly share code, notes, and snippets.

View ronzalo's full-sized avatar
🎯
coding...

Gonzalo Moreno ronzalo

🎯
coding...
View GitHub Profile
@ronzalo
ronzalo / Dockerfile
Created June 26, 2018 18:53
Python Dockerfile for Autolab autograding image
# Autolab - autograding docker image
FROM ubuntu:18.04
MAINTAINER Gonzalo Moreno <gonzalo.m@desafiolatam.com>
RUN apt-get update --fix-missing
RUN apt-get install -y gcc
RUN apt-get install -y make
RUN apt-get install -y build-essential
RUN apt-get install -y python
@ronzalo
ronzalo / diff.rb
Created September 2, 2019 20:11 — forked from ecleel/diff.rb
SequenceMatcher class in ruby. credit to testunit folks.
# port of Python's difflib.
#
# Copyright (c) 2001-2008 Python Software Foundation; All Rights Reserved
# Copyright (c) 2008-2011 Kouhei Sutou; All Rights Reserved
#
# It is free software, and is distributed under the Ruby
# license and/or the PSF license. See the COPYING file and
# PSFL file.
# Carry this code from testunit/testunit project.
@ronzalo
ronzalo / slack_file_deleter.rb
Created August 3, 2018 19:27
Script to delete old files on slack
# frozen_string_literal: true
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files(user = nil)
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
@ronzalo
ronzalo / Dockerfile
Created July 13, 2018 19:45 — forked from remarkablemark/Dockerfile
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@ronzalo
ronzalo / safe_merge.sh
Last active May 16, 2018 21:28 — forked from gonzalo-bulnes/safe_merge.sh
Some merging rules to make collaboration easier through repository order. Think of rebasing as updating the context in which you write your feature, see also: https://gonzalo-bulnes.github.io/blog/gardening_with_git/context-from-scratch.html
# safe merge
#
# merge the branch XXXXXXXX-add-example-feature into master
# make sure the feature is properly tested and
# doesn't break anything in its original context
git checkout XXXXXXXX-add-example-feature
rake # the test suite MUST NOT raise any error
# make sure your local copy of master is up-to-date
<?php
/*
*
* (c) Gonzalo Moreno C. <goncab380<at>hotmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@ronzalo
ronzalo / paperclip_has_destroyable_file.rb
Created October 6, 2016 14:47 — forked from sunny/paperclip_has_destroyable_file.rb
Rails Initializer to add destroyable attachments with Paperclip
# encoding: UTF-8
class ActiveRecord::Base
# Class method to add destroyable paperclip attachments.
#
# Example:
# has_attached_file :image
# has_destroyable_file :image
# attr_accessible :image_delete
#
@ronzalo
ronzalo / _form.html.erb
Created September 6, 2016 14:50
Coupon input in Spree cart
<!-- app/views/spree/orders/_form.html.erb -->
<%= order_form.text_field :coupon_code, :class => 'form-control', placeholder: Spree.t(:coupon_code) %>
@ronzalo
ronzalo / _property.html.erb
Created July 19, 2016 18:51
Spree promotion rule for properties
<!-- admin/promotions/rules/_property.html.erb -->
<div class="panel-body">
<div class="form-group property_rule_property_id">
<%= label_tag "#{param_prefix}_property_id_string", Spree.t('property_rule.choose_property') %>
<%= select_tag "#{param_prefix}[preferred_property_id]", options_from_collection_for_select(Spree::Property.all, "id", "presentation", promotion_rule.preferred_property_id), class: 'select2' %>
<%= label_tag "#{param_prefix}_value_string", Spree.t('property_rule.insert_value') %>
<%= text_field_tag "#{param_prefix}[preferred_value]", promotion_rule.preferred_value, class: 'form-control' %>
</div>
</div>
@ronzalo
ronzalo / gist:27b01228ac13f2b7e3d8
Created June 3, 2015 18:14
Taxon importer for spree_importer_core
class Spree::TaxonImporter < Spree::ImporterCore::BaseImporter
# Load a file and the get data from each file row
#
# @params
# row => "Hombre > Vestuario > Chaquetas > Parkas"
def load_data(row:)
return unless row[0].present?
taxons = row[0].split(">").map!(&:strip)
process_taxons(taxons)