Skip to content

Instantly share code, notes, and snippets.

View fakenickels's full-sized avatar
💭
hello this is a mic test, are you listening

Gabriel fakenickels

💭
hello this is a mic test, are you listening
View GitHub Profile
@fakenickels
fakenickels / branchWithResolver.js
Created September 1, 2017 23:59
High order component that shows a waiting component meanwhile a promise does not solve
import React from 'react';
const branchWithResolver = (promise, RightBranch, LeftBranch) => Component =>
class extends React.Component {
displayName = `branchWithResolver(${Component.name})`;
state = { isLoading: true };
componentDidMount = () =>
promise.then(() => this.setState({ isLoading: false }));
render = () =>
this.state.isLoading ? (
import React from 'react'
import ViewUsingModal from './ViewUsingModal'
export default Component =>
class ModalVisibility extends React.Component {
state = { isVisible: false }
toggleModalVisiblity = () => this.setState({ isVisible: !this.state.isVisible })
render() {
return <Component isModalVisible={this.state.isVisible} toggleModalVisibility={this.toggleModalVisibility} {...this.props} />
}
import React from 'react'
import { View, Text, Modal } from 'react-native'
import withModalVisibility from './ModalVisility'
const ViewUsingModal = ({ isModalVisible, toggleModalVisibility }) =>
<View>
<TouchableOpacity onPress={toggleModalVisibility}>
<Text>Tap me!</Text>
</TouchableOpacity>
<Modal visible={isModalVisible}>
import React from 'react'
export default (stateName, handlerName, defaultValue) => Component =>
class StateHandler extends React.Component {
state = { [stateName]: defaultValue }
constructor(props) {
super(props)
this[handlerName] = (value) => this.setState({ [stateName]: value })
}
@fakenickels
fakenickels / StyledComponentsDemo.re
Last active February 27, 2018 18:18
styled-components like for ReasonML
open ReactNative;
let component = ...
let Wrapper = Styled(View Style.(style [
flexDirection `row,
paddingHorizontal 20.,
]));
let Button = Styled(TouchableOpacity Style.(style[
@fakenickels
fakenickels / Styled.re
Created October 13, 2017 15:46
styled-components-ish similar for Reason
open ReactNative;
module type Config = {
let name: string;
let style: Style.t;
};
module Create (Config: Config) => {
let component = ReasonReact.statelessComponent Config.name;
let make = View.make style::Config.style;
open ReactNative;
module type StyledConfig = {type styleParams; let style: styleParams => Style.t;};
module View (Config: StyledConfig) => {
let make ::styled=? style::additionalStyle=Style.(style []) =>
View.make
style::(
Style.combine
(
@fakenickels
fakenickels / submodules.md
Created October 21, 2017 18:43 — forked from manasthakur/submodules.md
Using git submodules to version-control Vim plugins

Using git-submodules to version-control Vim plugins

If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need. Thus, you should keep the .vim directory along with your .vimrc version-controlled.

But when you have plugins installed inside .vim/bundle (if you use pathogen), or inside .vim/pack (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.

Creating the repository

Initialize a git repository inside your .vim directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:

cd ~/.vim
const withPromise = R.curry((propName, promise, Component) => class WithPromise extends React.Component { state = { [propName]: null } displayName = `WithPromise(${Component.displayName})` componentDidMount = () => promise(this.props).then(value => this.setState({ [propName]: value })).catch(something) render = () => <Component {...this.props} {this.state}/> })
@fakenickels
fakenickels / .circleci.yml
Created November 23, 2017 20:28
CircleCI with opam
version: 2
jobs:
build:
environment:
- GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
- TERM: xterm
docker:
- image: circleci/node:8.0
- image: circleci/android:api-23-alpha