Skip to content

Instantly share code, notes, and snippets.

View banhaclong20's full-sized avatar

Tom Tran banhaclong20

View GitHub Profile
@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"
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 / 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
@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 / 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 / if-el-onscreen.js
Created January 1, 2019 16:53
If ele on screen - js
// A simple jQuery function to check if the element is visible on screen
// https://gist.github.com/agaase/6648737
$.fn.isOnScreen = function() {
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();