This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * media.js | |
| * script para buscar medios embebeables en una url | |
| * por josé tomás albornoz - www.eljojo.net | |
| * usa trozos de código sacados de: https://twimg0-a.akamaihd.net/b/1/bundle/t1-more-en-201201121558.js | |
| */ | |
| var mediajs = { | |
| providers: { | |
| youtube:{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ [\1]/' | |
| } | |
| export PS1="\h:\W\$(parse_git_branch) \u\$ " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApplicationHelper | |
| # hand picked from http://www.grumdrig.com/emoji-list/ | |
| RANDOM_EMOJI = %w{🚳 🏊 🍕 🍔 🍟 🌽 🍉 🎣 🎅 👻 🎃 🐎 🐴 🐒 🐵 🐗 🐷 🐻 👴 🙀 👳 👮 👲 💏} | |
| def random_emoji(count = 5) | |
| RANDOM_EMOJI.shuffle[0..count].join(' ') | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pp' | |
| text = 'and the day is 08/11/1993 of course' | |
| regex = 'the (day) (.+) <date> of' | |
| result = regex.dup | |
| until (s ||= 0) >= result.length | |
| break unless section = (/(\((?!\?)(?:[^\(]+?[^\\]\)))/).match(result, s) | |
| matches = Regexp.new(result.gsub(/<.+?>/, '.+?')).match(text) | |
| offset = section.offset(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/assets/javascripts/turbolinks.js.coffee b/lib/assets/javascripts/turbolinks.js.coffee | |
| index 4f59e37..d1d0640 100644 | |
| --- a/lib/assets/javascripts/turbolinks.js.coffee | |
| +++ b/lib/assets/javascripts/turbolinks.js.coffee | |
| @@ -137,6 +137,7 @@ removeHash = (url) -> | |
| link.href.replace link.hash, '' | |
| triggerEvent = (name) -> | |
| + console.log 'trigering event', name | |
| event = document.createEvent 'Events' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # modification of http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails | |
| def humanize_seconds secs, precision = 2 | |
| return unless secs | |
| units = [[60, :second], [60, :minute], [24, :hour], [1000, :day]] | |
| diffs = units.map do |count, name| | |
| next if units.find_index([count, name]) > precision | |
| if secs > 0 | |
| secs, n = secs.divmod(count) | |
| pluralize(n.to_i, name.to_s) if n > 0 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class HTTPClient | |
| attr_accessor :old_tls, :use_ssl | |
| def initialize(opts = {}) | |
| config = { | |
| old_tls: true, | |
| use_ssl: nil, | |
| }.merge(opts) | |
| @old_tls = config[:old_tls] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AmazonItem | |
| attr_accessor :asin, :url, :manufacturer, :category, :title, \ | |
| :ean, :item_number, :model, :lowest_price, :image_url, \ | |
| :list_price, :offer_price | |
| def initialize(attributes = {}) | |
| update_attributes(attributes) | |
| end | |
| def update_attributes(new_attributes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| show_frown_gif = -> | |
| @result.html $('<img>').attr('src', 'http://mrwgifs.com/wp-content/uploads/2013/07/Zooey-Deschanels-Cute-Sad-Frown.gif') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class String | |
| def each_match(regex) | |
| result = [] | |
| position = 0 | |
| while match_data = regex.match(self, position) do | |
| result << if block_given? then yield(match_data) else match_data end | |
| position = match_data.end(match_data.size - 1) | |
| end | |
OlderNewer