Skip to content

Instantly share code, notes, and snippets.

View jaimeagudo's full-sized avatar

Jaime Agudo jaimeagudo

  • Freelance
View GitHub Profile
/**
Same signature as fetch. It returns a ready to use curl command with
{headers} optional JSON {body}, {method} and CLI {curlCliOptions}
curl('https://en.wikipedia.org/api/rest_v1/page/summary/Cehegin',
{
headers: { accept: 'application/json' },
body: {},
method: 'GET'
Firstly, we'll need to update the commit author in our local Git config:
$ git config --global user.name "Jaime Agudo"
$ git config --global user.email "jaimeagudo@users.no.reply.github.com"
Then, reset the author of all commits after a specific commit:
$ git rebase -i 956951bf -x "git commit --amend --reset-author -CHEAD"
You'll then be presented with your editor where you can confirm all the commits you want to change.
@jaimeagudo
jaimeagudo / usePrefetchRoute.js
Created September 21, 2021 16:13
usePrefetchRoute proposal
// @flow
import { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import * as routePaths from '~/constants/routes';
import { GET_SMART_CHARGING } from '~/state/products/ev-charger/actions';
const ROUTES_PREFETCH_ACTIONS = {
[routePaths.evChargerSettings]: {
type: GET_SMART_CHARGING,
routeArgsToActionPayload: ({ id, ...restOfNavigationArguments }) => ({ deviceId: id }),
@jaimeagudo
jaimeagudo / index.js
Created December 20, 2017 13:57
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var profanity = require('profanity-util');
console.log(profanity.purify('Brassie', {
obscureSymbol: '$'
}));
// [ 'foo p$$p', ['poop'] ]
@jaimeagudo
jaimeagudo / index.js
Created December 18, 2017 12:57
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var profanity = require('profanity-util');
console.log(profanity.purify('Brassie', {
obscureSymbol: '$'
}));
// [ 'foo p$$p', ['poop'] ]
@jaimeagudo
jaimeagudo / actions.js
Last active November 7, 2017 09:13
Redux action creators with "backbone.js syntax"
const restActionTypes = ['REQUEST', 'ADD_REQUEST', 'SUCCESS', 'REFRESH', 'FAILURE', 'SELECT', 'RESET', 'SAVE', 'PLATFORM_REQUEST', 'PLATFORM_SUCCESS', 'PLATFORM_FAILURE', 'PAYMENT_RESULT']
const authActionTypes = ['START', 'SUCCESS', 'FAILURE', 'EXPIRED', 'END', 'CACHE_REQUEST', 'CACHE_SUCCESS', 'CACHE_FAILURE', 'DECODED']
const fcmActionTypes = ['TOKEN_REFRESHED', 'TOKEN_SAVE', 'TOKEN_SAVED', 'NOTIFICATION_RECEIVED', 'TOPICS_RECEIVED', 'OPTIONAL_TOPICS_PREFS_LOAD', /* 'OPTIONAL_TOPICS_PREFS_SAVE', unused for now */ 'OPTIONAL_TOPICS_PREFS_UPDATED', 'BACKGROUND_DATA_RECEIVED']
const errorActionTypes = ['HTTP', 'AUTH', 'INTERNAL']
// Helper to build objects like the one below and prevent name clashes and typos
// { FAILURE:"USER_FAILURE"
// REQUEST:"USER_REQUEST"
// SELECT:"USER_SELECT"
// SUCCESS:"USER_SUCCESS"}
;http://www.4clojure.com/problem/39#prob-title
(= (#(let [result (zipmap % %2)]
(apply concat result)) [1 2 3] [:a :b :c])
'(1 :a 2 :b 3 :c))
(= (#(let [result (zipmap % %2)]
(apply concat result)) [1 2] [3 4 5 6])
'(1 3 2 4))

Keybase proof

I hereby claim:

  • I am jaimeagudo on github.
  • I am jal (https://keybase.io/jal) on keybase.
  • I have a public key whose fingerprint is 739B 7FE4 A527 8072 82F2 D03C 45A2 0F3D 8206 2E8C

To claim this, I am signing this object:

@jaimeagudo
jaimeagudo / 0. description.md
Created February 27, 2017 09:17 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.

Note: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,

@jaimeagudo
jaimeagudo / 0. description.md
Created February 27, 2017 09:16 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.

Note: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,