Skip to content

Instantly share code, notes, and snippets.

View oriolgual's full-sized avatar

Oriol Gual oriolgual

View GitHub Profile
@oriolgual
oriolgual / drm_is_bad.js
Created June 19, 2023 06:44
Download ebook from Tagus as images
IO.CS.readChunkSilent = function (a, b, c, d, e, f) {
var g = {};
Book.mode == Book.IMAGE &&
(
g = {
readMode: 'IMAGE',
imageSize: 'LARGE'
},
e = e ||
{
// Save as ~/.finicky.js
module.exports = {
defaultBrowser: "Safari",
handlers: [
{
match: /^https?:\/\/meet\.google\.com\/.*$/,
browser: "Google Chrome"
},
{
@oriolgual
oriolgual / autoconf.rb
Created May 2, 2021 07:35
Autoconf 2.69, needed to install Erlang with BigSur (fails with 2.71)
class Autoconf < Formula
desc "Automatic configure script builder"
homepage "https://www.gnu.org/software/autoconf"
url "https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz"
mirror "https://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz"
sha256 "954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969"
license all_of: [
"GPL-3.0-or-later",
"GPL-3.0-or-later" => { with: "Autoconf-exception-3.0" },
]
@oriolgual
oriolgual / yaml_to_csv.rb
Last active September 11, 2020 12:48
Converts all English YAML files in a Decidim folder to CSV or XLS
require "yaml"
require "csv"
def reduce_hash(value, parent = nil)
value.map do |key, value|
i18n_scope = [parent, key].compact.join(".")
if value.is_a?(Hash)
reduce_hash(value, i18n_scope)
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]
# 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

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:

@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
{
"age": {
"18-24": 82,
"25-34": 655,
"35-44": 210,
"45-54": 47,
"55+": 2
},
"position": {
"Developer": 485,