Skip to content

Instantly share code, notes, and snippets.

@brunolemos
brunolemos / destructuring.js
Last active September 14, 2016 16:34 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@brunolemos
brunolemos / keybase.md
Created February 6, 2017 21:57
Keybase proof

Keybase proof

I hereby claim:

  • I am brunolemos on github.
  • I am brunolemos (https://keybase.io/brunolemos) on keybase.
  • I have a public key whose fingerprint is CCB7 2FCA 5650 3F50 EEB4 F796 0A8E 45A6 ACE6 6963

To claim this, I am signing this object:

@brunolemos
brunolemos / ListView.js
Last active November 24, 2017 14:26
React Native - ListView receiving data as a prop <ListView data={[1,2,3]} />
import React from 'react';
import { ListView } from 'react-native';
export default class extends React.PureComponent {
constructor(props) {
super(props);
const { data, dataSource, rowHasChanged: _rowHasChanged } = props;
this.state.data = data || [];
@brunolemos
brunolemos / App.js
Last active December 10, 2017 17:37
HoC with custom prop name
@withTest('myNewPropName')
export default class App extends PureComponent...
@brunolemos
brunolemos / Example.jsx
Last active January 12, 2018 22:57
[react-native] Cross-platform TabView component with unified API for SegmentedControl (iOS default) and scrollable tabs (Android default)
// Live demo: https://snack.expo.io/@brunolemos/tabview
import React, { Component } from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import { Constants } from 'expo';
import TabView from './components/TabView';
const routes = [{ index: 0, title: 'Tab 0' }, { index: 1, title: 'Tab 1' }];
@brunolemos
brunolemos / TouchableScale.tsx
Created September 21, 2018 20:38
Touchable component with Scale effect, common on iOS 12 (works on mobile and web)
// Demo: https://snack.expo.io/@brunolemos/touch-button-scale-effect
import React from 'react'
import { Animated, StyleProp, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, ViewStyle } from 'react-native'
import { styleMerge } from 'shared/src/utils'
export interface TouchableScaleProps extends TouchableWithoutFeedbackProps {
containerStyle?: StyleProp<ViewStyle>
}
@brunolemos
brunolemos / PlatformTouchable.tsx
Last active September 28, 2019 20:22
TypeScript version of react-native-platform-touchable
// Source: https://github.com/react-community/react-native-platform-touchable
import React, { PureComponent, ReactNode } from 'react'
import {
BackgroundPropType,
Platform,
StyleProp,
TouchableNativeFeedback,
TouchableNativeFeedbackProperties,
TouchableNativeFeedbackStatic,
TouchableOpacity,
@brunolemos
brunolemos / ExampleComponent.tsx
Last active May 27, 2020 14:00
Redux + TypeScript - Strongly Typed
import React from 'react'
import { Button, Text, View } from 'react-native'
import { useDispatch } from 'react-redux'
import { useReduxState } from '../hooks/use-redux-state'
import * as actions from '../redux/actions'
import * as selectors from '../redux/selectors'
export function LoginScreen() {
const dispatch = useDispatch()
@brunolemos
brunolemos / darkify_slack.sh
Created November 22, 2018 05:59 — forked from ryanpcmcquen/darkify_slack.sh
Darkify your Slack.
#!/bin/sh
# Darkify Slack on Mac OS:
SLACK_INTEROP_JS="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js"
# Thanks to: https://gist.github.com/DrewML/0acd2e389492e7d9d6be63386d75dd99#gistcomment-2358430
if [ -z "`grep tt__customCss ${SLACK_INTEROP_JS}`" ]; then
# Backup original CSS for reverts:
cp ${SLACK_INTEROP_JS} ${SLACK_INTEROP_JS}.bak
echo 'document.addEventListener("DOMContentLoaded",function(){let tt__customCss=`body{background:#222;color:#e6e6e6}a{color:#949494}a:link,a:visited{color:#949494}a:active,a:focus,a:hover{color:#c7c7c7}hr{border-bottom:1px solid #424242;border-top:1px solid #222}h1,h2,h3,h4{color:#e6e6e6}h1 a{color:#e6e6e6}h1 a:active,h1 a:hover,h1 a:link,h1 a:visited{color:#e6e6e6}.bordered{border:1px solid #363636}.top_border{border-top:1px solid #363636}.bottom_border{border-bottom:1px solid #363636}.left_border{border-left:1px solid #363636}.right_border{border-right:1px solid #363636}.bullet{color:#949494}.alert,.c-alert,.c-alert--bo
@brunolemos
brunolemos / debounce.js
Created December 20, 2016 00:53
React Debounce Render
// usage:
// export default debounce(100)(MyComponent);
import React from 'react';
import debounce from 'lodash/debounce';
export default (interval, ...debounceArgs) => {
if (typeof interval !== 'number' && interval > 0) {
throw new Error('[debounce] Interval (ms) parameter not received.');
}