Skip to content

Instantly share code, notes, and snippets.

View peterpme's full-sized avatar
🏠
Working from home

Peter Piekarczyk peterpme

🏠
Working from home
View GitHub Profile
@peterpme
peterpme / state.es6
Last active January 18, 2016 21:56
Click Handlers in React
class Hello extends React.Component {
constructor() {
this.handleIncrement = this.handleIncrement.bind(this)
this.state = {
currentIndex: 0
}
}
@peterpme
peterpme / nvm-install.sh
Last active January 26, 2016 16:57
Given a `.nvmrc` file within your directory, automatically install the required node version
# belongs in ~/.zshrc
#chpwd is a zsh hook
function chpwd() {
[ -e .nvmrc ] && nvm install
}
@peterpme
peterpme / styles.less
Last active June 23, 2021 06:24
Operator Mono and Fira Code working together in Atom
// ...
atom-workspace,
atom-text-editor {
font-family: "Fira Code";
text-rendering: optimizeLegibility;
font-size: 17px;
font-weight: 400;
line-height: 1.8;
}
@peterpme
peterpme / binding-answer.es6
Last active August 26, 2016 15:49
How can I pass both the key and the value without resorting to bind?
const handleFieldUpdate = (key) => (value) => setState({ [key]: value })
const SomeForm = () => (
<Input
placeholder='Name'
onChange={handleFieldUpdate('name')}
/>
)
const Input = ({
@peterpme
peterpme / config
Created November 11, 2016 17:02
SSH Config Taken From Paul Irish. Thanks Paul!
# symlink to ~/.ssh/config
Host github.com
ControlMaster auto
ControlPersist 120
Host *
# Always use SSH2.
Protocol 2
@peterpme
peterpme / apollo-tote-authorization.js
Last active October 10, 2017 18:29
Apollo Tote Examples
<ApolloTote
query={`
query {
user {
id
}
}
`}
test={data => !!(data && data.user && data.user.id)}
handleFail={() => Store.dispatch({ type: 'LOG_OUT' })}
@peterpme
peterpme / apollo-tote-loading.js
Created October 10, 2017 18:31
Apollo Tote Loading
<ApolloTote
query={`
query {
user {
imageUrl
}
}
`}
renderLoading={() => <Avatar.Loading />}
render={value => <Avatar imageUrl={value.user.imageUrl} />}

Keybase proof

I hereby claim:

  • I am peterpme on github.
  • I am peterpme (https://keybase.io/peterpme) on keybase.
  • I have a public key ASDd9ipiMIdjkzvqnBaqXLvRHaN2-tVZtgHng-YSVYRv4Ao

To claim this, I am signing this object:

@peterpme
peterpme / updateResponse.js
Created December 30, 2017 21:29
React Apollo updateResponse Question
updateUser: (variables) => {
return mutate({
variables,
// when using optimisticResponse and I don't include the values, I get a warning.
optimisticResponse: {
updateUser: {
__typename: 'User',
id: 'xyz',
setting: undefined,
@peterpme
peterpme / environment.js
Last active June 1, 2018 13:33
Psuedo Environment Variables using Expo Release Channels
import { Constants } from 'expo'
const ENV = {
dev: {
apiUrl: 'http://localhost:1337/api'
},
staging: {
apiUrl: 'https://staging.orchard.ai/api'
},
prod: {