Skip to content

Instantly share code, notes, and snippets.

@joakin
joakin / dogfood.txt
Created December 12, 2015 12:59
dog food
144€ ahorro origen
orijen 13kg 66€
528€ x 8 meses
acana 18kg 67€
13kg 48€
384€ x 8 meses
ultima 7,5kg 26€
@joakin
joakin / cat.txt
Created December 16, 2015 15:55
HTML sizes of loot-ui in Cat
examples (master *%=) $ du -h output/Cat/*
16K output/Cat/slim-lead-no-json.html
28K output/Cat/slim-lead.html
580K output/Cat/slim-no-json.html
1.1M output/Cat/slim.html
@joakin
joakin / a.js
Last active April 6, 2016 11:54
var b = require('./b')
module.exports = function () {
return b(1)
}
@joakin
joakin / record.md
Created April 18, 2016 09:55
Recording http requests in tests in node

Integration (acceptance) tests that use the mediawiki action api and rest apis:

  • Take a long time to run (1m30s for #mobile-content-service)
    • Locally it destroys any TDD cycle or rapid feedback cycle
  • Are brittle to failures and other production conditions on such external services for continuous integration or local development.

There are known solutions for these problems, knowingly recording external http requests by running the tests and caching them, so that subsequent test runs use the cached results. See https://www.ctl.io/developers/blog/post/http-apis-test-code for informative post.

Requirements for such tool:

@joakin
joakin / vcr.txt
Created April 22, 2016 12:00
Testing recording mobile content service
mobileapps (record-http-sepia) $ VCR_MODE=record npm test
> [email protected] test /Users/jhernandez/dev/wikimedia/mobileapps
> mocha
express app
server options changed; restarting
✓ should get robots.txt (44ms)
@joakin
joakin / SpecialMobileCitations.php
Created May 12, 2016 17:58
Less branching, no empty returns
<?php
/**
* SpecialMobileCite.php
*/
/**
* Provides a list of citiations available for a page
*/
class SpecialMobileCite extends MobileSpecialPage {
@joakin
joakin / phab.js
Created May 20, 2016 14:56
canduit usage, node
const Canduit = require('canduit')
const init = (conf) => new Promise((res, rej) =>
Canduit(conf, (err, api) => err ? rej(err) : res(api)))
const run = (api, route, params) => new Promise((res, rej) =>
api.exec(route, params, (err, resp) => err ? rej(err) : res(resp)))
const conf = {
user: '<USERNAME>',
@joakin
joakin / phabricator-hates-you.user.js
Created June 10, 2016 12:55
Phabricator hates you back (userscript)
// ==UserScript==
// @name phabricator
// @namespace joaquino
// @include https://phabricator.wikimedia.org/*
// @version 1
// @grant none
// ==/UserScript==
document.body.onload = () => {
const animate = document.createElement('style')
@joakin
joakin / output.js
Created August 19, 2016 15:49
resource-modules output v1
{ files:
{ '/resources/mediawiki.template.hogan/hogan.js': { mw_requires: [ 'mw.template' ] },
'/resources/mobile.abusefilter/AbuseFilterOverlay.js':
{ requires: [ 'mobile.startup/Button', 'mobile.overlays/Overlay' ],
async_requires: [],
mw_requires: [ 'mw.template', 'mw.mobileFrontend' ],
templates: [ { module: 'mobile.abusefilter', fileName: 'Overlay.hogan' } ],
defines: [ 'mobile.abusefilter/AbuseFilterOverlay' ] },
'/resources/mobile.abusefilter/AbuseFilterPanel.js':
{ requires: [ 'mobile.view/View', 'mobile.abusefilter/AbuseFilterOverlay' ],
@joakin
joakin / test.js
Last active August 22, 2016 12:44
Hovercards EL tests
var $ = window.jQuery
var log = []
window.mw.trackSubscribe('event', (schema, e) => {
log.push([e.action, JSON.stringify(e)])
})
var STEPS = {
find_link: () => {
window.testel = $('a').filter((i, v) => v.textContent === 'Test')