Skip to content

Instantly share code, notes, and snippets.

View jCrip's full-sized avatar
🏠
Working from home

Juan Cristobal Pazos jCrip

🏠
Working from home
  • Modyo
  • Santiago, Chile
View GitHub Profile
@jCrip
jCrip / subpackageslist.txt
Created May 21, 2016 00:53
My starter packages for sublime.
"Advanced CSV",
"AdvancedNewFile",
"AlignTab",
"All Autocomplete",
"ApplySyntax",
"AutoFileName",
"Autoprefixer",
"BeautifyRuby",
"Better CoffeeScript",
"BracketHighlighter",
@jCrip
jCrip / filterable.rb
Created May 12, 2016 18:52 — forked from justinweiss/filterable.rb
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with the same name as the keys in <tt>filtering_params</tt>
# with their associated values. Most useful for calling named scopes from
@jCrip
jCrip / Advanced Classes
Created September 28, 2015 20:27 — forked from JoseJRVazquez/Advanced Classes
My Lesson in Advanced Classes in Ruby
Ok, so Inheritance
its not just for young white dudes waiting for their grandparents to fucking keel over at 82.
In ruby, Inheritance allows one class to inherit from another class attributes and behaviors (methods) that it didnt have before. The inheriter, much like a young white male, is the child class. The class that it inherits from, rather than being his old money grandparents, is the Parent Class. The lesson says Inheritance is designated with a < symbol, for example:
class Daughter < Father
end
wow, quick right. So for that, the daughter is getting methods from the father. Simple right. But lets go deeper and se how fucked up this can really get for those of us in the cheap seats.
echo "* Updating system"
apt-get update
apt-get -y upgrade
echo "* Installing packages"
apt-get -y install build-essential libmagickcore-dev imagemagick libmagickwand-dev libxml2-dev libxslt1-dev git-core nginx redis-server curl nodejs htop
id -u deploy &> /dev/null
if [ $? -ne 0 ]
then
@jCrip
jCrip / jquery_fallback.html
Created April 17, 2015 00:11
jQuery request with fallback
<!-- jQuery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/assets/js/vendor/jquery-1.11.1.min.js"><\/script>')</script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
@jCrip
jCrip / api.rb
Last active August 29, 2015 14:17
# This one goes to the API file.
before do
next if @resource
@req = ::AuthenticatedRequest.new(
uid: request.headers['Uid'],
token: request.headers['Access-Token'],
client: request.headers['Client'],
resource: @resource
)
@jCrip
jCrip / application_helper.rb
Created February 15, 2015 22:08
Rails 4 flash messages using Twitter Bootstrap(bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass).
module ApplicationHelper
def bootstrap_class_for flash_type
{ success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type.to_sym] || flash_type.to_s
end
def flash_messages(opts = {})
flash.each do |msg_type, message|
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} alert-dismissible", role: 'alert') do
concat(content_tag(:button, class: 'close', data: { dismiss: 'alert' }) do
@jCrip
jCrip / box-sizing.css
Last active August 29, 2015 14:13
Apply a natural box layout model to all elements, but allowing components to change
/* apply a natural box layout model to all elements, but allowing components to change */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
@jCrip
jCrip / basic_usage.php
Last active August 29, 2015 14:06 — forked from BaylorRae/basic_usage.php
Cycle function like the one in liquid or twig
<?php for( $i = 0; $i < 9; $i++ ) : ?>
<p><?php echo cycle('one', 'two', 'three') ?></p>
<?php endfor; ?>
@jCrip
jCrip / custom_add_to_cart.html
Last active August 29, 2015 14:01 — forked from juque/custom_add_to_cart.html
Bootic custom_add_to_cart
<!-- Formulario y botón "agregar al carro" en plantilla product.html.
Los data-attributes son necesarios para la API Ajax del carrito (opcional) -->
<form class="add_to_cart" action="{{ add_to_cart_url }}" method="post" data-bootic-cart-add="add" data-bootic-productId="{{ product.id }}">
<!-- si hay más de 1 variante, muéstralas en una lista -->
{% if product.variants_count > 1 %}
<h4>{{ 'activerecord.models.variant' | t }}</h4>
<ul class="variants">
<!-- primero las variantes disponibles -->
{% for variant in product.available_variants %}
<li class="bootic_variant available {% cycle 'odd', 'even' %} av-variant-{{ forloop.index }}">