Skip to content

Instantly share code, notes, and snippets.

View oriolgual's full-sized avatar

Oriol Gual oriolgual

View GitHub Profile
@oriolgual
oriolgual / agilecrm.js
Created December 1, 2015 15:05
AgielCRM unminifed JavaScript client
function agile_setAccount(b, a) {
agile_id.set(b, a);
agile_setEmailFromUrl()
}
function agile_setEmailFromUrl() {
if (window.location.href.search("fwd=cd") !== -1) {
try {
var a = decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURI("data").replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
if (a) {
@oriolgual
oriolgual / Gemfile
Created May 24, 2016 07:47
Script to mass move repositories from a GitHub user to another
source "https://www.rubygems.org"
ruby '2.2.4'
gem 'byebug'
gem 'capybara'
gem 'selenium-webdriver'
version: '2'
services:
app:
command: bash -c "rm -f tmp/pids/server.pid && bundle install --path /bundle && bundle exec rails s -p 3000 -b '0.0.0.0'"
build:
context: .
args:
rails_env: development
volumes:
- .:/code
@oriolgual
oriolgual / application_controller.rb
Created March 9, 2017 10:07
Example LogRage & Rails configuration
def append_info_to_payload(payload)
super
payload[:remote_ip] = request.remote_ip
payload[:user_id] = current_user.try(:id)
payload[:organization_id] = current_organization.try(:id)
payload[:app] = current_organization.name
payload[:referer] = request.referer.to_s
payload[:request_id] = request.uuid
payload[:user_agent] = request.user_agent
payload[:xhr] = request.xhr? ? 'true' : 'false'
{
"age": {
"18-24": 82,
"25-34": 655,
"35-44": 210,
"45-54": 47,
"55+": 2
},
"position": {
"Developer": 485,
@oriolgual
oriolgual / metrics.rb
Last active July 11, 2018 07:16
An example implementation of how to get and store metrics for Decidim
module Decidim
class OrganizationComponents < Rectify::Query
def self.for(organization)
new(organization).query
end
def initialize(organization)
@organization = organization
end

Keybase proof

I hereby claim:

  • I am oriolgual on github.
  • I am oriolgual (https://keybase.io/oriolgual) on keybase.
  • I have a public key ASBYUUGCVOTq29wGMNVCmEUXuMp8SGlcW1OqDiTYJta6JAo

To claim this, I am signing this object:

# Add this to Core's QueryExtensions
module Decidim
module QueryExtensions
type.field :metrics, [Decidim::Core::MetricType]
argument :names, types[String], "The names of the metrics you want to retrieve"
resolve lambda { | _, args, ctx|
manifests = if args[:names].blank?
metrics_registry.all
else
@oriolgual
oriolgual / circleci-to-rspec.rb
Created February 28, 2019 09:41
Extracts RSpec failed examples from a CircleCI build so you can run them locally
require "open-uri"
require "json"
if ARGV.length < 3
puts "Usage: ruby circle-to-rspec.rb CIRCLE_CI_TOKEN RSPEC_STEP_NAME BUILD_URL"
puts "You can get your CircleCI token at https://circleci.com/account/api"
exit(0)
end
circle_token = ARGV[0]