Skip to content

Instantly share code, notes, and snippets.

View LinusBorg's full-sized avatar
I may be slow to respond.

Thorsten Lünborg LinusBorg

I may be slow to respond.
View GitHub Profile
@FilipBartos
FilipBartos / axios-response-interceptor.js
Last active April 11, 2024 07:03
Axios response interceptor for access token refresh supporting 1 to N async requests
let isAlreadyFetchingAccessToken = false
let subscribers = []
function onAccessTokenFetched(access_token) {
subscribers = subscribers.filter(callback => callback(access_token))
}
function addSubscriber(callback) {
subscribers.push(callback)
}
@leodutra
leodutra / mapStatesTwoWay.vuex.js
Last active June 9, 2019 09:09
Function for mapping Vuex states two way
import { mapState } from 'vuex'
export default function mapStatesTwoWay (namespace, states, updateCb) {
const mappedStates = mapState(namespace, states)
const res = {}
for (const key in mappedStates) {
res[key] = {
set (value) {
updateCb.call(this, { [key]: value })
},
// place this file in __mocks__
let pendingAssertions
exports.prompt = prompts => {
if (!pendingAssertions) {
throw new Error(`inquirer was mocked and used without pending assertions: ${prompts}`)
}
const answers = {}
@bmingles
bmingles / some-component.ts
Created December 12, 2017 02:44
Making Vuex stores type safe
import { Dispatcher } from './store';
export default Vue.component('some-component', {
template,
created() {
this.fetchData();
},
methods: {
/**
* Fetch our data.
@daffl
daffl / readme.md
Last active November 26, 2017 20:48
Upgrading to Feathers v3 (Buzzard)
@learner-long-life
learner-long-life / Rinkeby.md
Last active August 30, 2022 22:32
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@chartinger
chartinger / TestHelper.js
Created January 11, 2017 10:47
Simple Vue.js shallow render helper
import Vue from 'vue'
const mockComponent = function (name, props) {
return {
props: props,
render: function (createElement) {
return createElement(name, { props: props })
}
}
}
function translateError(msg) {
var newErr = new Error(msg); // placed here to get correct stack
return e => {
newErr.originalError = e;
throw newErr;
}
}
async function asyncTask() {
const user = await UserModel.findById(1).catch(translateError('No user found'))
function promisifyFileReader (filereader) {
function composeAsync (key) {
return function () {
var args = arguments
return new Promise (function (resolve, reject) {
//
function resolveHandler () {
cleanHandlers()
resolve(filereader.result)
}
@heyimalex
heyimalex / example.js
Created September 21, 2016 16:15
Using mock-fs with jest
// __tests__/example.js
jest.mock('fs');
it('should serve as a nice example', () => {
const fs = require('fs')
// fs can be set up at any point by calling __configureFs.
fs.__configureFs({
'/test': {