Skip to content

Instantly share code, notes, and snippets.

Avatar
:electron:
Q U A R A N T I N E D

Peter Piekarczyk peterpme

:electron:
Q U A R A N T I N E D
View GitHub Profile
@peterpme
peterpme / ReactColor.re
Last active Oct 20, 2020
React-Color ReasonML Binding
View ReactColor.re
open BsTinycolor;
open Belt;
type colorChange = {
.
"hex": string,
"hsl": TinyColor.hsl,
"hsv": TinyColor.hsv,
"oldHue": float,
"rgb": TinyColor.rgb,
@peterpme
peterpme / fbd.zsh
Created Jul 30, 2020
Interactive git branch delete
View fbd.zsh
# fbd - delete git branch (including remote branches)
fbd() {
local branches branch
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
branch=$(echo "$branches" | fzf --multi ) &&
git branch -D $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}
## place this in your ~/.zshrc and make sure you have fzf installed: brew install fzf
@peterpme
peterpme / PatternMatching.re
Created May 13, 2020
ReasonML Pattern Matching
View PatternMatching.re
type action = Toggle | Close | Edit;
let reducer = switch(action) {
| Toggle => "toggle visibility"
| Close => "close me"
| Edit => "edit function"
};
View graphql.rq
let (result) = useQuery(ComponentList.definition);
switch(result) {
| Loading => <LoadingSpinner />
| Error(err) => <ErrorMessage message={err##message} />
| Data(data) => {
switch(data##componentsList) {
| None => []
| Some(components) => components->Belt.Array.map(component => <div> component##value </span>
}
@peterpme
peterpme / InteriorLayout.re
Created Dec 13, 2018
ReasonReact render props
View InteriorLayout.re
[@genType]
let make = (~render, ~children) => {
...component,
render: _self =>
<div className="InteriorLayout">
{render()}
</div>,
};
@peterpme
peterpme / Broken-Navigator.bs.js
Last active Oct 26, 2018
Using match_, match in Reason Bug. `Broken-` prefix console.log(match) = undefined
View Broken-Navigator.bs.js
// Generated by BUCKLESCRIPT VERSION 4.0.5, PLEASE EDIT WITH CARE
import * as React from 'react'
import * as ReasonReact from 'reason-react/src/ReasonReact.js'
require('./Navigator.css')
var component = ReasonReact.statelessComponent('Navigator')
function make(history, match__, _) {
View black-bg.js
document.body.style.backgroundColor = 'black'
@peterpme
peterpme / withLoadingScreen-4.js
Created Apr 23, 2018
Loading Screen with Naming
View withLoadingScreen-4.js
import * as React from "react";
import hoistNonReactStatics from 'hoist-non-react-statics';
import { View, ActivityIndicator } from "react-native";
const withLoadingScreen = (size = "small") => WrappedComponent => {
class LoadingScreen extends React.PureComponent {
render() {
if (this.props.loading) return <ActivityIndicator size={size} color="white" />
return <WrappedComponent {...this.props} />;
}
@peterpme
peterpme / compose-imports.js
Created Apr 20, 2018
compose imports from redux / react-apollo
View compose-imports.js
import { compose } from "redux";
import { compose } from "react-apollo";
// your InfoScreen implementation
// bottom of file:
export default compose(
connect(mapStateToProps, mapActionCreators),
withLoadingScreen
)(InfoScreen)
@peterpme
peterpme / withLoadingScreen-3.js
Created Apr 19, 2018
withLoadingScreen HOC with options
View withLoadingScreen-3.js
import * as React from "react";
import hoistNonReactStatics from 'hoist-non-react-statics';
import { View, ActivityIndicator } from "react-native";
const withLoadingScreen = (size = "small") => WrappedComponent => {
class LoadingScreen extends React.PureComponent {
render() {
if (this.props.loading) return <ActivityIndicator size={size} color="white" />
return <WrappedComponent {...this.props} />;
}
You can’t perform that action at this time.