Skip to content

Instantly share code, notes, and snippets.

Avatar

Jaime Agudo jaimeagudo

  • Freelance
View GitHub Profile
View reset-author git commits
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 Sep 21, 2021
usePrefetchRoute proposal
View usePrefetchRoute.js
// @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 Dec 20, 2017
requirebin sketch
View index.js
// 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 Dec 18, 2017
requirebin sketch
View index.js
// 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 Nov 7, 2017
Redux action creators with "backbone.js syntax"
View actions.js
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"}
View prob_39.clj
;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))
View keybase.md

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 Feb 27, 2017 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
View 0. description.md
  • 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 Feb 27, 2017 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
View 0. description.md
  • 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 / EmojiTextFieldDelegate.swift
Created Nov 9, 2016
Udacity iOS emoji textfield, functionally seasoned
View EmojiTextFieldDelegate.swift
//
// EmojiTextFieldDelegate.swift
// TextFields
//
// Created by Jason on 11/11/14.
// Copyright (c) 2014 Udacity. All rights reserved.
//
import Foundation
import UIKit