Skip to content

Instantly share code, notes, and snippets.

View estrattonbailey's full-sized avatar

Eric Bailey estrattonbailey

View GitHub Profile
@typpo
typpo / async analytics.js
Created August 5, 2017 20:05
MIT License
// Create a queue to push events and stub all methods
window.analytics || (window.analytics = {});
window.analytics_queue || (window.analytics_queue = []);
(function() {
var methods = ['identify', 'track', 'trackLink', 'trackForm', 'trackClick', 'trackSubmit', 'page', 'pageview', 'ab', 'alias', 'ready', 'group', 'on', 'once', 'off'];
var factory = function(method) {
return function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(method);
import React, { Component, PropTypes } from 'react'
import ReactDOM from 'react-dom'
import throttle from 'lodash/throttle'
import { INTERVAL } from './constants.js'
let bound // are the event handlers bound?
let current // current scroll position, from top of document
let queue // array of React Components to check
@nathandao
nathandao / .Xmodmap
Last active September 22, 2019 20:57
Linux keyboard mapping & configurations for macbook pro
keycode 66 =
keycode 66 = Control_L
keycode 133 =
keycode 133 = Meta_L
keycode 64 = Alt_L
clear mod1
clear mod4
@mutewinter
mutewinter / README.md
Last active February 8, 2018 21:16
Magic Import for Vim UltiSnips

Magic Import for Vim UltiSnips

GIF of magic import in action

  1. Be a Vim user.
  2. Install UltiSnips.
  3. Add the code below to $YOUR_VIM_FOLDER/UltiSnips/javascript.snippets.
snippet ii "magic import" b
import `!p
@kennetpostigo
kennetpostigo / Migrating.md
Last active June 2, 2021 17:44
How I migrated from ReactRouter v2 to v4

First couple things I thought about when migrating after reading the docs

So migrating my existing app wasn't as troublesome as I originally thought. First thing I did was take a look at my router and routes and figure try to make a mental model of all the files where I had nested routes in the existing app because those components/containers will contain {this.props.children}. So I need to replace those with the nested <Match /> components.

So just to give an example:

In v2:

<Router history={history}>
  <Route path="/" component={App}>
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
<!--
* Liquid Snippet for generating responsive image srcsets based on Shopify's native image transforms.
* Published June 17, 2016 by Joseph Bergdoll
* www.extendedplay.nyc
*
* Full list of Shopify's generated image transforms:
* https://ecommerce.shopify.com/c/ecommerce-design/t/very-important-please-read-new-image-sizes-supported-up-to-2048x2048-for-retina-support-110766
*
* Simply include it within your image element, define the `image`, and the maximum size.
* Product Images and Theme Asset Images should have either `product: 'true'` or `asset: 'true'` declared, respectively.
@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active April 18, 2025 13:48
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@matthiasak
matthiasak / diy-routing.js
Last active March 28, 2016 16:51
Copy the following code into https://matthiasak.github.io/arbiter-frame/#// to see it run
const router = (routes, fn=(a,b)=>a(b)) => {
let current = null
const listen = () => {
window.addEventListener('hashchange', () => {
trigger(window.location.hashname.slice(1))
})
}
const trigger = path => {
@daggerhart
daggerhart / simple-php-template.php
Last active June 30, 2021 14:44
Example of a template function in PHP
<?php
/**
* Simple PHP Templating function
*
* @param $names - string|array Template names
* @param $args - Associative array of variables to pass to the template file.
* @return string - Output of the template file. Likely HTML.
*/
function template( $names, $args ){
// allow for single file names