Skip to content

Instantly share code, notes, and snippets.

View banhaclong20's full-sized avatar

Tom Tran banhaclong20

View GitHub Profile
@banhaclong20
banhaclong20 / .eslintrc
Created January 16, 2018 03:28 — forked from radiovisual/.eslintrc
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
import serializeForm from 'form-serialize'
const getLocalStorage = (key) => {
let data = null
try { data = JSON.parse(localStorage[key]) } catch() {}
return data
}
const setLocalStorage = (key, data) => {
localStorage[key] = JSON.stringify(data)
@banhaclong20
banhaclong20 / searchkit-update-query.jsx
Created March 11, 2018 00:21 — forked from rippedspine/searchkit-update-query.jsx
first solution to update searchkit elastic query on prop change
import React from 'react'
import _set from 'lodash/set'
import _get from 'lodash/get'
const searchkit = new SearchkitManager(`/elastic/materials`, {
withCredentials: true
})
class SearchApp extends SearchkitComponent {
@banhaclong20
banhaclong20 / searchkit-load-more.jsx
Created March 11, 2018 00:21 — forked from rippedspine/searchkit-load-more.jsx
Proof of concept, load more component with searchkit accessors
import React from 'react'
import _debounce from 'lodash/debounce'
import _get from 'lodash/get'
import {
SearchkitComponent,
PageSizeAccessor
} from 'searchkit'
import React, { Component } from 'react';
import extend from 'lodash/extend';
import { SearchkitManager,SearchkitProvider,
SearchBox, Pagination, HitsStats, NoHits, ViewSwitcherHits,
Layout, TopBar, LayoutBody, LayoutResults,
ActionBar, ActionBarRow, QueryAccessor} from 'searchkit';
import './index.css';
import {
SearchkitAutosuggest, HierarchicalRefinementDatasource,
import React, { Component } from "react";
import { render } from "react-dom";
import "./index.css";
class Widget extends Component {
state = { text: "" };
handleChange = (e) => {
this.setState({ text: e.target.value });
};
render() {
@banhaclong20
banhaclong20 / example01.js
Created March 17, 2018 21:35 — forked from mpj/example01.js
Code for the async/await episode of Fun Fun Function.
const response = await fetch(`https://catappapi.herokuapp.com/users/${userId}`)
const data = await response.json()
return data.imageUrl
}
@banhaclong20
banhaclong20 / basic.md
Created April 15, 2018 18:13 — forked from zenorocha/basic.md
New Firebase Auth vs Old Firebase Auth
@banhaclong20
banhaclong20 / firebase_storage_multi_file_upload.js
Created April 19, 2018 00:21 — forked from asciimike/firebase_storage_multi_file_upload.js
Upload multiple files transactionally in Firebase Storage
// set it up
firebase.storage().ref().constructor.prototype.putFiles = function(files) {
var ref = this;
return Promise.all(files.map(function(file) {
return ref.child(file.name).put(file);
}));
}
// use it!
firebase.storage().ref().putFiles(files).then(function(metadatas) {
// Object.keys(searchkit).map(key =>
// console.log(searchkit[key])
// )
// for (var key in searchkit) {
// // skip loop if the property is from prototype
// if (!searchkit.hasOwnProperty(key)) continue;
// var obj = searchkit[key];