Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Baby Yoda is my spirit animal

Berkeley Martinez BerkeleyTrue

💭
Baby Yoda is my spirit animal
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am berkeleytrue on github.
  • I am berkeleytrue (https://keybase.io/berkeleytrue) on keybase.
  • I have a public key ASD1MZchoq-cqZLSU9kXEzrmAeDyVXR_DI9v_bk_19me8Qo

To claim this, I am signing this object:

@BerkeleyTrue
BerkeleyTrue / .travis.yml
Created Jun 5, 2018
greenkeeper lockfile install with npm ci
View .travis.yml
language: node_js
node_js:
- '8'
- '10'
before_install:
- if [[ `npm -v` != 6* ]]; then npm install -g npm@6; fi
- npm install -g greenkeeper-lockfile
View event-handler-with-context.jsx
class MyComponent extends React.Component {
constructor() {
this.handleClick = this.handleClick.bind(this);
}
handleClick(e) {
console.log('Parameter', this.props.param);
console.log('Event', e);
}
View event-handlers-with-parameters-bind-constructor.js
class MyComponent extends React.Component {
constructor() {
this.handleClick = this.handleClick.bind(this, 'Parameter');
}
handleClick(param, e) {
console.log('Parameter', param);
console.log('Event', e);
}
@BerkeleyTrue
BerkeleyTrue / .profile
Created Sep 2, 2017
Checkout remote pull request
View .profile
gcorpullrequest() {
# gcorpullrequest 123 upstream
# gcorpullrequest 124
remote=origin
echo "What do you want to call the local branch?"
read branchname
if [ $# = 2 ]; then
View karabiner.json
{
"title": "SpaceKeys",
"rules": [
{
"description": "l/r shift => ()",
"manipulators": [
{
"description": "Change left shift press to (",
"from": {
"key_code": "left_shift",
View throw-in-mergemap.js
function epic(actions){
return actions.ofType('FOO')
.mergeMap(action => {
const transformed = transform(action); // may throw collapsing the pipe
return makeThingDoAsyncy(transform)
.catch(e => [foo(e)]); // won't catch above
});
}
// imperative
@BerkeleyTrue
BerkeleyTrue / np.sh
Created Apr 7, 2017 — forked from stevemao/np.sh
Publish node module
View np.sh
# npm publish with goodies
# prerequisites:
# `npm install -g trash conventional-recommended-bump conventional-changelog conventional-github-releaser conventional-commits-detector json`
# `np` with optional argument `patch`/`minor`/`major`/`<version>`
# defaults to conventional-recommended-bump
# and optional argument preset `angular`/ `jquery` ...
# defaults to conventional-commits-detector
np() {
travis status --no-interactive &&
trash node_modules &>/dev/null;
View arrow-v-method-bind.jsx
export class BadFunComp extends React.PureComponent {
handleFun() {
const { funApi } = this.props;
funAPi();
}
render() {
// displayCoolness.props.handleFun will always have a new ref value
// causes child to re-render on ever BadFunComp render
return (
<DisplayCoolness onFun={ () => this.handleFun() } />
View arrayToServiceToArray.js
const serviceValues = [ 2, 3, 4 ];
// convert values array into a stream of individual values: Obs[...num]
return Observable.of(serviceValues)
// call service on each value and get Observable in return: Obs[Obs[newValFromService]]
.map(val => serviceApi(val))
// convert stream of observables into a stream of a single array of observables Obs[ [Obs[newVal]] ]
.toArray()
// trigger all the service calls with maximum concurrenct
.switchMap((serviceCalls) => Observable.combineLatest(serviceCalls))
.subscribe(newVals => console.log('new values from server: ', newVals)) // [...{id: 2, ...data}, {id: 3, ...dat}]
You can’t perform that action at this time.