Skip to content

Instantly share code, notes, and snippets.

View whichsteveyp's full-sized avatar

Stephen Rivas Jr whichsteveyp

View GitHub Profile
@whichsteveyp
whichsteveyp / es5.js
Created March 10, 2015 17:54
I was not aware of the two syntax styles here. Are there valid uses/reasons for both?
// one
[].each(function (foo) {
return foo.info ? "hello" : "hi";
});
// two
[].each(function (foo) {
return foo.info ? "hello" : "hi";
});
source ~/.git-completion.sh
source ~/.git-prompt.sh
export PS1='\n\n\[\e[0;36m\][ \[\e[0;35m\]\w\[\e[0;36m\] ] $(__git_ps1 "\[\e[1;33m\]%s\[\e[0;36m\]") >\[\e[0m\] '
@whichsteveyp
whichsteveyp / .git-prompt.sh
Created September 16, 2013 22:07
Ivan deletes things for no reason.
__gitdir ()
{
# Note: this function is duplicated in git-completion.bash
# When updating it, make sure you update the other one to match.
if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then
echo "$__git_dir"
elif [ -n "${GIT_DIR-}" ]; then
test -d "${GIT_DIR-}" || return 1
echo "$GIT_DIR"
// const AppDispatcher =, etc...
module.exports = {
getCommentsForRequestWithBind(requestID, rowBusinessKey) {
superagent.get(`/api/${requestID}/comments`, this.updateRequestCommentsInRow.bind(this, requestID, rowBusinessKey), someGlobalErrorAction);
},
getCommentsForRequestLambda(requestID, rowBusinessKey) {
superagent.get(`/api/${requestID}/comments`, comments => this.updatedRequestCommentsInRow(requestID, rowBusinessKey, comments), someGlobalErrorAction);
},
@whichsteveyp
whichsteveyp / App.js
Created April 2, 2016 17:20
Considering usage for React Context - Localization/Utilities
// imports & variables, etc
ReactDOM.render(
<Localization messageBundle={{ foo: 'Welcome', bar: 'This is', baz: 'a website' }}>
<Provider store={Store}>
<Router history={history}>
<Route path="/" component={SomeParentRenderingGrandchildrenThatWantLocalizedStrings}>
</Router>
</Provider>
</Localization>,
@whichsteveyp
whichsteveyp / children-as-function.js
Last active May 25, 2016 02:11 — forked from iammerrick/children-as-function.js
Which API do you prefer? Passing a function into the Ratio component or making a higher order component called Ratio you can use to configure a component.
// parent A wants to show a list
<GetLastNImagesOfType type="jpg" numImages={10}>
{(images) => {
return images.map(image => <span>{image.name}</span>)
}}
</GetLastNImagesOfType>
// parent B wants to show the images themselves
<GetLastNImagesOfType type="jpg" numImages={10}>
{(images) => {
import B from './ComponentB-map.jsx';
export default const A = React.creatClass({
render() {
const { wrapperStyle, BStyleMap } = this.props.style;
// now you have to grok A's map, as well as B's map _and_ hope B has a map that supports the
// customization that you would want B to support when in this A context
return (
@whichsteveyp
whichsteveyp / .git-completion.sh
Created September 16, 2013 22:07
Also he's a Bull's Fan. Idiot.
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
const API = ({ match, data }) => {
// this i left as is
const { params: { mod, header, environment } } = match;
const doc = data.api.find(doc => mod === doc.title.slug);
// don't mind the tern here as much, maybe would split the find to its own `validDocHeaderMatch`
const validHeader = doc && (header ? !!doc.headers.find(h => h.slug === header) : true );
// this is my 😍 for conditional JSX thus far
return <Block>
{!doc && <Redirect to={`/${environment}`}/>}
@whichsteveyp
whichsteveyp / App.jsx
Created July 6, 2017 02:01
Stephen vs Promises
import React from 'react';
import Component from './Component.jsx';
export default class App extends React.Component {
render() {
return <Component options={{ autoplay: true }}>
{(status, video) => {
// this error is being caught in the promise in component render, even though