Skip to content

Instantly share code, notes, and snippets.

Pere Joan Martorell pjmartorell

Block or report user

Report or block pjmartorell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pjmartorell / mask_phone_number.rb
Last active Aug 5, 2019
Mask phone with asterisks except last 3 characters
View mask_phone_number.rb
phone = '+36637950242'; phone[0..-4] = '*' * phone[0..-4].length; phone
# OR
phone = '+36637950242'; phone.gsub(/.(?=.{3})/,'*')
pjmartorell /
Last active Dec 5, 2019
How to download subtitles/text tracks of a On Demand Vimeo video

Download subtitles/text tracks of an On-Demand Vimeo video

It works with on-demand videos that have the subtitles/captions included (CC symbol). You need to be registered in Vimeo in order to retrieve subtitles.


  1. Open Chrome Developer Tools
  2. Start playing the Vimeo video
  3. Look for any request named segment-XX.m4s (where XX is a number)
  4. Select the request and inspect the request payload, which is something in the form:
View package_fitting_checker.rb
module Delivery
class PackageFittingChecker
def, quantities_with_max_units_and_shipping_package_categories)
case shipping_method_id
when "correos", "d_post"
max_units_per_package = :max_units_per_correos_package
when "ups_envelope"
max_units_per_package = :max_units_per_ups_package
when "dhl", "ups_express_saver", "ups_standard"
return true
View quantities_with_max_units_and_shipping_package_categories_mapper.rb
module Delivery
class QuantitiesWithMaxUnitsAndShippingPackageCategoriesMapper
def initialize(cart_products)
@cart_products = cart_products
def quantities_with_max_units_and_shipping_package_categories do |cart_product|
variant = cart_product.sample_pack_product.presence || cart_product.variant.presence
raise "Unsupported type! #{cart_product.inspect}" unless variant
pjmartorell /
Created Jun 28, 2017
Cuba framework resources and examples

Source code


pjmartorell / git-checkout.rake
Last active Sep 9, 2016 — forked from sunny/git-checkout.rake
Task to checkout a branch in rails and apply or rollback the migrations between the two.
View git-checkout.rake
# encoding: UTF-8
# $ rake checkout new_branch_name
# Via
# 1. Roll back any migrations on your current branch which do not exist on the
# other branch
# 2. Discard any changes to the db/schema.rb file
# 3. Check out the other branch
View Google Maps Simple Multiple Marker Example
<title>Google Maps Multiple Markers</title>
<script src="" type="text/javascript"></script>
<div id="map" style="height: 400px; width: 500px;">
<script type="text/javascript">
pjmartorell /
Last active May 6, 2016
Find the symmetric difference between Amazon S3 object list and your local files list
#!/usr/bin/env bash
comm -13 <(aws s3 ls s3://my-bucket | awk '{print $NF}' | sort) <(ls my_local_folder/ | awk '{print $NF}' | sort)
pjmartorell / laravel_naming.php
Last active May 5, 2016
Laravel Naming Conventions
View laravel_naming.php
class MyClass {
const MY_CONSTANT = 0.0;
protected $myProperty;
protected $table = [
pjmartorell / MapSVG.js
Last active May 6, 2016
Function to fetch the region name from the region ID in mapSVG WordPress plugin Can be used for Global tooltips or popovers
View MapSVG.js
/* Function to fetch the region name from
the region ID in mapSVG WordPress plugin
Can be used for Global tooltips or popovers */
function (event, region) {
return '<b>' +," "); + '</b>';
You can’t perform that action at this time.