Skip to content

Instantly share code, notes, and snippets.

View srph's full-sized avatar
🛠️
Building @Stride-Labs Frontend

Kier Borromeo srph

🛠️
Building @Stride-Labs Frontend
View GitHub Profile
import React from 'react'
import { Flex } from 'jsxstyle'
class Column extends React.Component {
render () {
return <Flex {...this.props} direction="column"/>
}
}
export default Column

Hi Zach :D

Modals are funny beasts, usually they are a design cop-out, but that's okay, designers have to make trade-offs too, give 'em a break.

First things first, I'm not sure there is such thing as a "simple" modal that is production ready. Certainly there have been times in my career I tossed out other people's "overly complex solutions" because I simply didn't understand the scope of the problem, and I have always loved it when people who have a branch of experience that I don't take the time

@jondlm
jondlm / README.md
Last active January 3, 2018 05:59
React shallow render lifecycle breakdown

React introduced shallow rendering in 0.13. This is an excellent feature that I wish was included earlier in React. It aims to solve the problem of unit testing components without going through a real, or jsdom mocked, DOM. I couldn't find any info online about what lifecycle events it actually fires. So I did some testing of my own. To reproduce, put component.js and test.js into a folder and run node test.js.

TLDR; shallow rendering only invokes the following lifecycle hooks (in order):

  1. getDefaultProps
  2. getInitialState
  3. componentWillMount stops here until re-render
  4. componentWillReceiveProps
  5. shouldComponentUpdate
  6. componentWillUpdate
// I want:
if (let x = someExpensiveFunction()) {
// Do stuff with X
}
// To be equivalent to:
(function() {
function LongestWord(sen) {
if (typeof LongestWord.cache === 'undefined') {
LongestWord.cache = [];
} else {
if (LongestWord.cache.hasOwnProperty(sen)) {
return LongestWord.cache[sen];
}
}
LongestWord.cache[sen] = sen
.match(/[\w]+/g)
@Urbiwanus
Urbiwanus / gist:c1e456f889f53e940a11
Last active November 13, 2019 15:38
Cordova Paypal Integration AngularJS
app.factory('PaypalService', ['$q', '$ionicPlatform', 'shopSettings', '$filter', '$timeout', function ($q, $ionicPlatform, shopSettings, $filter, $timeout) {
var init_defer;
/**
* Service object
* @type object
*/
var service = {
@pH200
pH200 / cycle.js
Last active July 6, 2017 05:30
Small Todo by using Cycle.js
import Cycle, {Rx, h} from 'cyclejs';
Cycle.registerCustomElement('TodoList', (rootElem$, props) => {
let vtree$ = props.get('items$').map(items =>
h('div', h('ul', items.map((itemText, index) =>
h('li', { key: index + itemText }, itemText)))));
rootElem$.inject(vtree$);
});
let vtree$ = Cycle.createStream(function (interaction$) {
@joshwcomeau
joshwcomeau / AnimalAndDog.js
Last active February 2, 2016 04:11
An example of concatenative inheritance
var animal = {
position: [0,0],
species: "mammal",
move: function(distance, axis) {
axis === 'x'
? this.position[0] += distance
: this.position[1] += distance;
}
}
@vsouza
vsouza / .bashrc
Last active April 20, 2025 21:15
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).