Skip to content

Instantly share code, notes, and snippets.

View banhaclong20's full-sized avatar

Tom Tran banhaclong20

View GitHub Profile
@banhaclong20
banhaclong20 / functional-utils.js
Created December 22, 2018 05:28 — forked from bendc/functional-utils.js
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@banhaclong20
banhaclong20 / normalize.css
Created August 21, 2018 16:36 — forked from joshvermaire/normalize.css
normalize.css for modern browsers and IE 10+
/*! normalize.css v2.0.1 | MIT License | git.io/normalize */
/*! modified by Josh Vermaire to remove support IE8-9 */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*
* Prevents modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
@banhaclong20
banhaclong20 / index.js
Created August 21, 2018 00:32 — forked from cereallarceny/index.js
Server-side rendering in Create React App
const md5File = require('md5-file');
const path = require('path');
// CSS styles will be imported on load and that complicates matters... ignore those bad boys!
const ignoreStyles = require('ignore-styles');
const register = ignoreStyles.default;
// We also want to ignore all image requests
// When running locally these will load from a standard import
// When running on the server, we want to load via their hashed version in the build folder
import React from 'react';
import { connect } from 'react-redux';
class PageWidget extends React.Component {
componentDidMount() {
this.ifr.onload = () => {
this.ifr.contentWindow.postMessage('hello', '*');
};
}
@banhaclong20
banhaclong20 / pots.js
Created May 30, 2018 03:20 — forked from saigowthamr/pots.js
Posts react helmet
import React from "react";
import { Helmet } from "react-helmet";
export default () => (
<div>
<Helmet>
<title>Ideas || MysiteName</title>
<meta name="keywords" content="HTML,CSS,JavaScript" />
<meta
name="description"
@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) {
@banhaclong20
banhaclong20 / basic.md
Created April 15, 2018 18:13 — forked from zenorocha/basic.md
New Firebase Auth vs Old Firebase Auth
@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
}
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() {
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,