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
function promisifyFileReader (filereader) {
function composeAsync (key) {
return function () {
var args = arguments
return new Promise (function (resolve, reject) {
//
function resolveHandler () {
cleanHandlers()
resolve(filereader.result)
}
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'))
@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 })
}
}
}
@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,

@daffl
daffl / readme.md
Last active November 26, 2017 20:48
Upgrading to Feathers v3 (Buzzard)
@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.
// 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 = {}
@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 })
},
@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)
}
@taurus227
taurus227 / !Git hooks for NPM projects
Last active July 26, 2022 20:49 — forked from betorobson/post-checkout
git hook to run `npm install` after git pull, merge, rebase or checkout if package.json was changed
# The name for this gist (starts with exclamation mark, because the name of the gist is the name of the first file in ASCIIbetical order)