Skip to content

Instantly share code, notes, and snippets.

View chinhnguyen's full-sized avatar
😎
Actively looking for remote contract work

Chinh Nguyen chinhnguyen

😎
Actively looking for remote contract work
View GitHub Profile
@chinhnguyen
chinhnguyen / muiStoriesOf.js
Created October 5, 2019 13:07
Override storybook add to make it work with material UI
import React from 'react';
import { storiesOf as storybookStoriesOf } from '@storybook/react';
import { StylesProvider } from '@material-ui/styles';
const generateClassName = (rule, styleSheet) => `${styleSheet.options.classNamePrefix}-${rule.key}`;
export default function storiesOf(kind, module) {
let stories = storybookStoriesOf(kind, module)
let _add = stories.add
//add: (storyName: string, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>;
@chinhnguyen
chinhnguyen / CBLReplication+Rx.swift
Created January 20, 2019 09:01
Make CBLReplication to return Observable<Double> to monitor the progress
func sync(remote syncURL: String, for store: Store) -> Observable<Double> {
// Make sure url is set
guard !syncURL.isEmpty, let url = URL(string: syncURL) else {
return Observable.error(RemoteSyncError.badConfiguration)
}
// Make sure the store contains a session
guard let session = store.syncSession else {
return Observable.error(RemoteSyncError.missingSyncSession)
}
// Make sure store is good