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 / 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(/-+$/, '');
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",
@EQuimper
EQuimper / pck.json
Created January 8, 2017 14:15
ex jest script
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
},
"jest": {
"setupFiles": ["./test/jestsetup.js"],
"snapshotSerializers": [
"<rootDir>/node_modules/enzyme-to-json/serializer"
]
@EQuimper
EQuimper / index.js
Created January 18, 2017 14:39
Using ref in functional component
function CustomForm ({handleSubmit}) {
let inputElement
return (
<form onSubmit={() => handleSubmit(inputElement.value)}>
<input
type='text'
ref={(input) => inputElement = input} />
<button type='submit'>Submit</button>
</form>
)
@EQuimper
EQuimper / index.txt
Created February 4, 2017 20:18
Find port for close
lsof -i:3000
<Menu widths={3}>
<Menu.Item name="" />
<Menu.Item><img src={logo} /></Menu.Item>
<Menu.Item name="Hello" />
</Menu>
@EQuimper
EQuimper / now.json
Created February 25, 2017 19:56
Now without build
"now-build": "echo 'not building'"
@EQuimper
EQuimper / index.txt
Created March 19, 2017 00:19
Update pck with yarn
yarn upgrade-interactive