Skip to content

Instantly share code, notes, and snippets.

View EQuimper's full-sized avatar
🏠
Working from home

Emanuel Quimper EQuimper

🏠
Working from home
View GitHub Profile
@EQuimper
EQuimper / index.js
Created November 29, 2016 06:26
Object literal for replace switch
function getDrink (type) {
var drinks = {
'coke': 'Coke',
'pepsi': 'Pepsi',
'lemonade': 'Lemonade',
'default': 'Default item'
};
return 'The drink I chose was ' + (drinks[type] || drinks['default']);
}
@EQuimper
EQuimper / sh
Created December 2, 2016 21:28 — forked from rexlow/md
Run React Native on specific iOS simulator version
//by default
//react-native run-ios
//iPhone 4
react-native run-ios --simulator "iPhone ${1:-4}"
//iPhone 4s
react-native run-ios --simulator "iPhone ${1:-4s}"
//iPhone 5
@EQuimper
EQuimper / children.js
Created December 3, 2016 03:03
Children in react
import React from 'react';
const checkSize = size => {
switch (size) {
case 'large':
return 100;
case 'medium':
return 75;
default:
return 50;
@EQuimper
EQuimper / ListView.js
Created December 13, 2016 15:07 — forked from brunolemos/ListView.js
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 || [];
@EQuimper
EQuimper / email.js
Created December 18, 2016 07:22
Email postmark example of use
if (!process.env.FROM_EMAIL) {
console.log('Please set: FROM_EMAIL environment variable. This is a validated email address to send emails from to other users for email verification, reset pwd etc')
process.exit();
}
if(!process.env.POSTMARK_API_TOKEN) {
console.error('Error! Please set POSTMARK_API_TOKEN from postmark email service.');
process.exit();
}
export const slugifyText = text =>
text
.toString()
.toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, '');
@EQuimper
EQuimper / hideOnScroll.js
Created January 2, 2017 01:47 — forked from mmazzarolo/hideOnScroll.js
react-native-action-button hide on scroll
// 1. Define a state variable for showing/hiding the action-button
state = {
isActionButtonVisible: true
}
// 2. Define a variable that will keep track of the current scroll position
_listViewOffset = 0
// 3. Add an onScroll listener to your listview/scrollview
<ListView
const routes = (
<Router history={browserHistory}>
<Route path="/">
<Route path="/posts/:id" component={PostPage} />
</Route>
</Router>
)
<button onClick={() => browserHistory.push(`/posts/${post.id}`)}></button>
@EQuimper
EQuimper / pkg.json
Created January 8, 2017 13:21
Idea of script and ghook
{
"name": "component-archetype",
"version": "0.0.1-semantic",
"description": "A new Webpack boilerplate with hot reloading React components, and error handling on module and component level.",
"main": "lib/index.js",
"scripts": {
"clean": "rimraf lib",
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"build:babel": "NODE_ENV=lib babel src --out-dir lib",
"build": "npm run clean && npm run build:babel",