Skip to content

Instantly share code, notes, and snippets.

View carlesjove's full-sized avatar

Carles Jove i Buxeda carlesjove

View GitHub Profile
@carlesjove
carlesjove / custom_wp_gallery
Last active November 28, 2018 17:18
Custom gallery markup for WordPress. Put this un functions.php and it will override the default shortcode.
@carlesjove
carlesjove / substitute_with
Created February 21, 2014 15:18
Substitute With
(function( $ ){
$.fn.substitute_with = function(r, w) {
$(this).html($(this).text().split(r).join(w));
return this;
};
})( jQuery );
// Usage example
# Devise 3.1.0
ca:
devise:
confirmations:
confirmed: "El teu compte ha estat confirmat correctament. Si us plau, inicia la sessió."
confirmed_and_signed_in: "El teu compte ha estat confirmat correctament. S'ha iniciat la sessió."
send_instructions: 'En breu rebràs un correu electrònic amb instruccions sobre com confirmar el teu compte.'
send_paranoid_instructions: "Si la teva adreça electrònica existeix a la base de dades, rebràs un correu electrònic amb instruccions sobre com confirmar el teu compte."
failure:
@carlesjove
carlesjove / fetch_img_src
Last active August 29, 2015 14:03
Fetch Img Src
/**
* Fetch Img Src
* Helper function to get an image source from an <img> tag
*/
function tm_fetch_img_src( $img_tag ) {
return preg_match( '@src="([^"]+)"@' , $img_tag , $src );
}
@carlesjove
carlesjove / gist:a8fccbd3acd7a2ed278f
Created October 8, 2014 10:23
Doubts regarding the usage of Colelction+JSON

Collection+JSON is a hypermedia-type for APIs.

  1. When using the inline property, which lets you nest C+J objects, how deep can the nesting go? Can, by instance, nested collections have templates?
  2. Imagine a template that can take multiple elements of a given kind (i.e. a Customer to which we can add multiple Addresses). How does this multiplicity reflect on the template?
@carlesjove
carlesjove / gist:a98abf4a9e21532bbca7
Last active August 29, 2015 14:07
My Funny Prompt
# Configure Terminal prompt
get_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
get_ruby_version() {
ruby -e "print RUBY_VERSION"
# If you're using rbenv and want to know
# the local version and not the global
# use this instead:
@carlesjove
carlesjove / so_28002853.rb
Created January 19, 2015 06:47
SO 28002853
require "minitest/autorun"
12
11 module Numerics
10 def twenty_one?(*nums)
9 nums.inject(&:+) == 21
8 end
7 end
6
5 class TestNumerics < MiniTest::Test
4 include Numerics
@carlesjove
carlesjove / spec_meta_dsl.rb
Last active August 29, 2015 14:17
Draft for a CJ Spec definition that includes meta data
# Commented lines mean that this would be the assumption unless otherwise is not specified
# so:
# unless validates_as: is specified, it is validated as a :string
# unless required: true is specified, it is required: false
module CollectionJson
module Spec
definition do
defines :href, validates_as: :url
@carlesjove
carlesjove / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console