Skip to content

Instantly share code, notes, and snippets.

View baldurh's full-sized avatar

Baldur Helgason baldurh

  • Jiko
  • Reykjavík, Iceland
View GitHub Profile
@baldurh
baldurh / extract-plural-rules.js
Created October 17, 2019 07:29
A script for generating plural rule files to use with i18next-icu. Based on https://github.com/formatjs/formatjs/blob/master/packages/intl-pluralrules/scripts/cldr.ts
const { writeFileSync } = require("fs");
const { resolve } = require("path");
const serialize = require("serialize-javascript");
const plural = require("make-plural");
const languages = [
"de",
"en",
"es",
let (left, width) =
Webapi.Dom.(
switch (Js.toOption(node)) {
| Some(element) =>
switch (
element |> Element.querySelector("[aria-selected=\"true\"]")
) {
| Some(element) =>
switch (element |> Element.asHtmlElement) {
| Some(element) => (

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@baldurh
baldurh / cloudinary-url-regex.js
Last active May 4, 2021 13:38
A regex for capturing different parts of cloudinary urls
const CLOUDINARY_REGEX = /^.+\.cloudinary\.com\/(?:[^\/]+\/)(?:(image|video)\/)?(?:(upload|fetch)\/)?(?:(?:[^_/]+_[^,/]+,?)*\/)?(?:v(\d+|\w{1,2})\/)?([^\.^\s]+)(?:\.(.+))?$/;
const url = 'http://res.cloudinary.com/oz/image/upload/v1454951830/moments/musicreach/f3432155-1be9-4510-9c3a-c1672c21fc89/f5de39a0-7ad0-48de-b53b-1d148856bcb8_540_pv.jpg';
const matches = CLOUDINARY_REGEX.exec(url);
console.log(matches);
/*
[
'http://res.cloudinary.com/oz/image/upload/v1454951830/moments/musicreach/f3432155-1be9-4510-9c3a-c1672c21fc89/f5de39a0-7ad0-48de-b53b-1d148856bcb8_540_pv.jpg',
'image', // resource_type
'upload', // type
{
"data": {
"channel": { "$type": "ref", "value": ["refs", "71e448a6-34df-41c9-bcc4-7df545c926e0"] },
"videosCollections": [
{ "collection": { "$type": "ref", "value": ["refs", "3081cda6-93a8-4e28-9775-53eb4822ecb2"] } },
{ "collection": { "$type": "ref", "value": ["refs", "541abf48-5799-48db-a3d0-9104849693af"] } },
{ "collection": { "$type": "ref", "value": ["refs", "cfd04bfc-0da0-49e0-9ddf-167fde37b2ae"] } },
{ "video": { "$type": "ref", "value": ["refs", "66e9f40f-7cca-458c-ad73-4a746e29c38a"] } }
],
"schedule": {
@baldurh
baldurh / output
Created August 1, 2014 09:54
Bracket matcher 0.51.0 installation output
> [email protected] install /private/var/folders/kl/qzzjpl1x2l55vxxkplw26s2c0000gn/T/apm-install-dir-11471-59280-m0zike/node_modules/bracket-matcher/node_modules/first-mate/node_modules/oniguruma
> node-gyp rebuild
CC(target) Release/obj.target/oniguruma/deps/onig/regcomp.o
CC(target) Release/obj.target/oniguruma/deps/onig/regenc.o
CC(target) Release/obj.target/oniguruma/deps/onig/regerror.o
CC(target) Release/obj.target/oniguruma/deps/onig/regexec.o
CC(target) Release/obj.target/oniguruma/deps/onig/regext.o
CC(target) Release/obj.target/oniguruma/deps/onig/reggnu.o