Skip to content

Instantly share code, notes, and snippets.

/**
<div> -- track 'top' of scrollable parent
-- track 'scrollLeft' of container to move fixed header
<Table.Container>
<Table.Header>
<Table.Row> -- clone row and set 'top' and 'position: fixed'
<Table.HeaderCell /> -- track dimensions of original row cells
-- bind dimensions of cloned row cells to tracked cells
</Table.Row>
</Table.Header>
@justinobney
justinobney / Pagination.js
Last active June 7, 2018 20:47
Pagination.md
import React, {Component} from 'react';
import {Menu} from 'semantic-ui-react';
import segmentize from 'segmentize';
import min from 'lodash/min';
import max from 'lodash/max';
import p from 'prop-types';
export class PaginationContainer extends Component {
static propTypes = {
render: p.func,
import faker from "faker";
import { isUndefined, times, shuffle} from "lodash";
// const data = shuffle(
// times(10, x => ({
// order: x,
// id: faker.internet.email(),
// name: faker.name.findName()
// }))
// );
@justinobney
justinobney / Context.js
Last active April 5, 2018 02:52
React-L10N
import React, {PureComponent} from 'react';
import isFunction from 'lodash/isFunction';
const I18nContext = React.createContext();
export const i18nDictionary = {
'en-US': safeTranslationAccessor({
'navigation.report-issue': 'Report Issue',
'navigation.logout': 'Log Out',
'dashboard.favorites': 'Favorites',
class AngularComponent {
static $inject = [];
constructor(...args) {
this.$inject = this.constructor.$inject.reduce(
(acc, injectName, index) => ({
...acc,
[injectName]: args[index],
}),
{}
const cases = (testName, ...testCases) => (test) => testCases.forEach(args=>it(testName, async () => test(...args)));
describe('Test Cases', () => {
const multiply = (x,y) => x*y;
cases(
'can multiply things...',
[1,2,2],
[2,2,4],
[3,3,9],
@justinobney
justinobney / git-cleanup.ps1
Created June 8, 2017 13:44
Windows GIT Cleanup
git branch --merged | ?{-not ($_ -like "*master")} | %{git branch -d $_.trim()}
git branch --no-merged | ?{-not ($_ -like "*master")} | %{git branch -D $_.trim()}

dataloader clone

  • exercise in cloning facebook/dataloader without reading source

Ex

// fake api call accepting [...keys]
function getData(keys) {
 return Promise.resolve(
var criteria = 'remote react';
var comments = document.querySelectorAll('.comment-tree .athing');
[].slice.call(comments).forEach((e) => {
var terms = criteria.split(' ');
var matches = terms.every(t=>(e.innerText.match(new RegExp(t, 'gi')) || []).length)
if(!matches){
e.style.display = 'none'
}
})
[
"http://www.echojs.com/rss",
"http://blog.andyet.com/rss",
"http://www.2ality.com/feeds/posts/default",
"http://feeds.feedburner.com/addyosmani",
"http://blog.angularjs.org/feeds/posts/default",
"http://feedpress.me/iawa",
"http://feeds.feedburner.com/dillingerMedia",
"http://feeds.feedburner.com/badassjs",
"http://builtwithreact.io/feed.xml",